You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.6 KiB

  1. 'use strict';
  2. angular.module('app.navbar', ['ngRoute'])
  3. .config(['$routeProvider', function($routeProvider) {
  4. $routeProvider.when('/navbar', {
  5. templateUrl: 'views/navbar/navbar.html',
  6. controller: 'NavbarCtrl'
  7. });
  8. }])
  9. .controller('NavbarCtrl', function($scope, $http, $routeParams, $location) {
  10. $scope.searchString = "";
  11. $scope.locationHash = $location.path();
  12. console.log($scope.locationHash);
  13. $scope.goBack = function() {
  14. console.log("goBack");
  15. window.history.back();
  16. };
  17. $scope.search = function() {
  18. console.log($scope.searchString);
  19. window.location.href = "#!/search/" + $scope.searchString;
  20. };
  21. if (localStorage.getItem("cr_webapp_userdata")) {
  22. $scope.storageuser = JSON.parse(localStorage.getItem("cr_webapp_userdata"));
  23. console.log($scope.storageuser);
  24. }
  25. //get the num of pendent notifications each time
  26. $http.get(urlapi + 'numnotifications')
  27. .then(function(data) {
  28. $scope.storageuser.notifications = data.data;
  29. console.log(data.data);
  30. localStorage.setItem("cr_webapp_storageuser", JSON.stringify($scope.storageuser));
  31. }, function(data) {
  32. console.log('data error');
  33. });
  34. $scope.logout = function() {
  35. localStorage.removeItem("cr_webapp_token");
  36. localStorage.removeItem("cr_webapp_userdata");
  37. window.location.reload();
  38. };
  39. });