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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
angular
.module('theme.core.notifications_controller', [])
.controller('NotificationsController', ['$scope', '$filter', '$http', function($scope, $filter, $http) {
'use strict';
$scope.notifications = [
text: 'Bienvenue',
time: '4m',
class: 'notification-success',
iconClasses: 'glyphicon glyphicon-ok',
id: '554',
seen: true
];
$scope.setSeen = function(item, $event) {
var id = angular.element(item).data('id'); // CETTE LIGNE NE RECUPERE PAS MON ID data-id='{{id}}'
$http ({
method: 'GET',
url: 'make_viewnotif.php?view=true&id='+ id , // URL DE MON FICHIER INCLUANT L'ID POUR LA MODIFICATION MYSQL
}).then(function successCallback(response) {
alert(id); // L'ALERT ME RETOURN UNDEFINED
$event.preventDefault();
$event.stopPropagation();
item.seen = true;
}, function errorCallback(response) {
alert("Une erreur est survenue, merci de ré-éssayer plus tard.");
});
};
$scope.setUnseen = function(item, $event) {
$event.preventDefault();
$event.stopPropagation();
item.seen = false;
};
$scope.setSeenAll = function($event) {
$event.preventDefault();
$event.stopPropagation();
angular.forEach($scope.notifications, function(item) {
item.seen = true;
});
};
$scope.unseenCount = $filter('filter')($scope.notifications, {
seen: false
}).length;
$scope.$watch('notifications', function(notifications) {
$scope.unseenCount = $filter('filter')(notifications, {
seen: false
}).length;
}, true);
}]); |
Partager