'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"));
});
});