client/app/search/search_controller.js
changeset 197 8b87432acffc
parent 188 fd75c66c8e30
child 201 5f54f408cc44
equal deleted inserted replaced
196:e3d3cd7a676a 197:8b87432acffc
    10         });
    10         });
    11     })
    11     })
    12     .controller('searchCtrl', function($scope, $location, $routeParams, searchApi, $modal, Slide){
    12     .controller('searchCtrl', function($scope, $location, $routeParams, searchApi, $modal, Slide){
    13         $scope.q = $routeParams.q || '';
    13         $scope.q = $routeParams.q || '';
    14         if ($scope.q !== ''){
    14         if ($scope.q !== ''){
    15             $scope.results_ = searchApi.searchResource({q:$scope.q, of: 'json', synthesis: 'false', nresults:'10', callback: 'JSON_CALLBACK'}).getJsonp();
    15           $scope.results = searchApi.searchResource({q:$scope.q, of: 'json', synthesis: 'false', nresults:'10', callback: 'JSON_CALLBACK'}).getJsonp();
    16         }
    16         }
    17         
    17 
    18         $scope.toggleModal = function (index) {
    18         $scope.toggleModal = function (index) {
    19 
    19 
    20             var modalInstance = $modal.open({
    20             var modalInstance = $modal.open({
    21                 templateUrl: 'search/modal.html',
    21                 templateUrl: 'search/modal.html',
    22                 controller: 'ModalInstanceCtrl',
    22                 controller: 'ModalInstanceCtrl',
    32             });
    32             });
    33         };
    33         };
    34     })
    34     })
    35     .controller('ModalInstanceCtrl', function ($scope, $modalInstance, Book) {
    35     .controller('ModalInstanceCtrl', function ($scope, $modalInstance, Book) {
    36         $scope.books = Book.query({format:'json'});
    36         $scope.books = Book.query({format:'json'});
    37         
    37 
    38         $scope.addToBook = function(idBook){
    38         $scope.addToBook = function(idBook){
    39             $modalInstance.close(idBook);
    39             $modalInstance.close(idBook);
    40         };
    40         };
    41 
    41 
    42         $scope.cancel = function () {
    42         $scope.cancel = function () {