123456789101112131415161718192021222324252627 |
- (function ()
- {
- 'use strict';
- app.controller('Header', [ '$scope','$translate', 'books.repository', '$rootScope','$location',function ($scope, $translate, booksRepository, $rootScope, $location){
- $scope.isLogged = function() {
- return localStorage.getItem('authToken') ? true : false;
- };
- $scope.langSwitch = function(){
- var lang = localStorage.getItem('preferredLanguage');
- var curentleng = lang === 'en'? 'ru' : 'en';
- $translate.use(curentleng);
- localStorage.setItem('preferredLanguage', curentleng);
- };
- $scope.search = function() {
- booksRepository.searchBy($scope.searchString)
- .then(function(response){
- sessionStorage.setItem('searchResult', JSON.stringify(response.data))
- $rootScope.$broadcast('search', response.data);
- $location.path('/books')
- })
- }
- }
- ]);
- }
- )();
|