There is a ready html:
<div ng-repeat="notification in vm.notifications" class="notifications"> <notification notification="notification"></notification> </div>
It draws the following directives:
app.directive('notification', function($compile){ return { restrict: 'E', transclude: true, replace: true, scope: { notification: "=notification" }, link: function(scope, element) { var temp = "<notifications" + scope.notification.type.normalCase() + ">"; var link = $compile(temp); var content = link(scope); element.append(content); } } }); app.directive('notificationsStudentRequest', function(){ return { template: '<div class="alert alert-info alert-dismissible"><button type="button" class="close" ng-click="vm.deleteNotification(notification)"><span aria-hidden="true">×</span></button>Запрос на участие в курсе: "{{notification.payload.course.name}}"</div>', restrict: 'EC', replace: true, transclude: true } }); app.directive('notificationsStudentRequestAccepted', function(){ return { template: '<div class="alert alert-success alert-dismissible"><button type="button" class="close" ng-click="vm.deleteNotification(notification)"><span aria-hidden="true">×</span></button>[{{ notification.createdAt | date}}] Запрос на участие в курсе: "{{notification.payload.course.name}}" был принят</div>', restrict: 'EC', replace: true, transclude: true } }); app.directive('notificationsStudentRequestRejected', function(){ return { template: '<div class="alert alert-danger alert-dismissible"><button type="button" class="close" ng-click="vm.deleteNotification(notification)"><span aria-hidden="true">×</span></button>[{{ notification.createdAt | date}}] Запрос на участие в курсе: "{{notification.payload.course.name}}" был отклонен</div>', restrict: 'EC', replace: true, transclude: true } });
The directives have a button to delete the item. The function is as follows:
vm.deleteNotification = function(notification){ vm.notifications.splice(vm.notifications.indexOf(notification), 1); }
<div ng-repeat="notification in vm.notifications" class="notifications"> Если кнопку создать тут, то она работает отлично и удаляет всё как положенно. Тоисть функция отрабатывает. </div>
But if the button is specified in the directive template, then it is simply not active. Tell me why this is happening?