I have a notification service which works well for when page is loaded and Controller is loaded
But when I have different buttons calling different functions, they change message, but alerts don't show up
Here is a plunker for that - http://plnkr.co/edit/YioiJXNkaET6T2mexjCq?p=preview
What is that I need to do to update it whenever $scope.message
changes?
You could $watch
the model and show the alert when it changes. http://plnkr.co/edit/fJuP9LWH4MNVV1cQs3ED?p=preview
In linker function of your directive:
link: function(scope, element, attrs) {
scope.$watch('ngModel', function() {
element.show();
$timeout(function(){
//element.empty();
element.hide();
}, 5000);
});
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.