javascript - Angular scope not updated on rootscope event -
i'm making notification banner application data not refresh in dom when update after listening rootscope event.
i've tried put code $timeout or use $digest , $apply , not work.
here place update viewmodel in controller:
const event = $rootscope.$on('notifications.updated', (event, notifications) => { const notification = notifications ? notifications.values().next().value : null; if (notification) { _setnotification(notification); } else { _resetnotification(); } vm.enabled = !!notification; }); here directive declaration:
function notificationbannerdirective() { return { restrict : 'e', replace : true, templateurl : 'templates/directives/notificationbanner.html', scope : {}, controller : notificationbannercontroller, controlleras : 'vm', bindtocontroller: true }; } here full declaration of directive , controller:
and here template:
<div class="notification-banner {{vm.enabled ? 'show' : ''}} {{vm.size || vm.constnotifications.sizes.medium}} {{vm.level || vm.constnotifications.levels.minor}}"> <p class="message">{{vm.message}}</p> <p class="action" ng-if="vm.action" ng-click="vm.action.callback()">{{vm.action.message}}</p> <a class="button button-icon icon ion-close" ng-if="vm.canclose" ng-click=""></a> </div> thanks!
Comments
Post a Comment