Parent: [146b7d] (diff)

Download this file

controllers.js    33 lines (22 with data), 983 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
'use strict';
angular.module('tut.c2net')
.controller('helloWorldController', function($scope, getHelloWorld) {
getHelloWorld.then(function(message) {
$scope.message = message;
});
})
.controller('c2netNotificationController', function($scope, livenotification, userNotificationAPI) {
$scope.notifications = [];
livenotification('/usernotification').on('usernotification:created', onNotifCreat);
function onNotifCreat(creatNotif){
$scope.notifications.unshift(creatNotif);
}
userNotificationAPI.list().then( function (response) {
$scope.notifications = response.data;
}, function(err) {
console.log("Error happened when receiving data from API", err)
}).finally(function() {});
$scope.$on('$destroy', function() {
livenotification('/usernotification').removeListener('usernotification:created', console.log("closed"));
});
});