| author | rougeronj |
| Tue, 07 Apr 2015 12:00:14 +0200 | |
| changeset 74 | 44ebb0d0b836 |
| parent 55 | 10fd23382e76 |
| child 82 | 6a5e84bf859c |
| permissions | -rw-r--r-- |
(function(){ 'use strict'; angular.module('ammicoSearch',['ngResource', 'ngRoute', 'ui.bootstrap']) .config(function ($routeProvider) { $routeProvider .when('/', { templateUrl: 'search/search.html', controller: 'searchCtrl' }); }) .controller('searchCtrl', function($scope, $location, $routeParams, searchApi, $modal){ $scope.q = $routeParams.q || ''; $scope.results = searchApi.searchResource({q:$scope.q, of: 'json', synthesis: 'false', nresults:'10', callback: 'JSON_CALLBACK'}).getJsonp(); $scope.toggleModal = function (index) { var modalInstance = $modal.open({ templateUrl: 'search/modal.html', controller: 'ModalInstanceCtrl', size: 'sm' }); modalInstance.result.then(function (idBook) { var newSlide = { book: idBook, idInventory: $scope.results.hits[index].metas_dict.inventorynumber }; searchApi.listSlides.save(newSlide); }); }; }) .controller('ModalInstanceCtrl', function ($scope, ammicoApi, $modalInstance) { $scope.books = ammicoApi.listBooks.query({format:'json'}); $scope.addToBook = function(idBook){ $modalInstance.close(idBook); }; $scope.cancel = function () { $modalInstance.dismiss('cancel'); }; }); })();