--- a/frontend/js/c2net/controllers.js
+++ b/frontend/js/c2net/controllers.js
@@ -5,4 +5,29 @@
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"));
+ });
+
+
});
+
+