header.controller.js 740 B

12345678910111213141516171819202122232425262728
  1. (function() {
  2. 'use strict';
  3. app.controller('Header', headerController);
  4. function headerController($scope, booksRepository, $location, $rootScope, utils) {
  5. $scope.isLogged = function() {
  6. return localStorage.getItem('authToken') ? true : false;
  7. };
  8. $scope.search = function() {
  9. booksRepository.searchBy($scope.searchString).then(function(response) {
  10. sessionStorage.setItem('searchResult', JSON.stringify(response.data));
  11. $location.path('/books');
  12. $rootScope.$broadcast('searchEvent', response.data);
  13. }, function(error) {});
  14. }
  15. }
  16. headerController.$inject = [
  17. '$scope',
  18. 'books.repository',
  19. '$location',
  20. '$rootScope',
  21. 'utils'
  22. ];
  23. })();