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.
 
 
 

33 lines
1.2 KiB

'use strict';
angular.module('app.notifications', ['ngRoute'])
.config(['$routeProvider', function($routeProvider) {
$routeProvider.when('/notifications', {
templateUrl: 'views/notifications/notifications.html',
controller: 'NotificationsCtrl'
});
}])
.controller('NotificationsCtrl', function($scope, $http) {
$scope.notifications = [];
$http.get(urlapi + 'notifications')
.then(function(data) {
//get the storage notifications
if (localStorage.getItem("cr_webapp_notifications")) {
$scope.notifications = JSON.parse(localStorage.getItem("cr_webapp_notifications"));
$scope.notifications = $scope.notifications.concat(data.data); // for UI
} else {
$scope.notifications = data.data;
}
//store the notifications
localStorage.setItem("cr_webapp_notifications", JSON.stringify($scope.notifications));
console.log($scope.notifications);
}, function(data) {
console.log('data error');
toastr.error("Error connecting server");
});
});