Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UI Notifications with angular js

Tags:

angularjs

I have to implement some standard notification UI with angular js. My approach is the following (simplified):

<div ng-controller="MainCtrl">
  <div>{{message}}</div>
  <div ng-controller="PageCtrl">
     <div ng-click="showMessage()"></div>
  </div>
</div>

And with the page controller being:

module.controller("PageCtrl", function($scope){
  counter = 1
  $scope.showMessage = function(){
    $scope.$parent.message = "new message #" + counter++;
  };
});

This works fine. But I really don't like the fact that I need to call $scope.$parent.

Because if I am in another nested controller, I will have $scope.$parent.$parent, and this becomes quickly a nightmare to understand.

Is there another way to create this kind of global UI notification with angular?

like image 444
standup75 Avatar asked Jun 18 '13 15:06

standup75


People also ask

What is push notifications in angular?

Introduction to Push NotificationsThe Push API is what allows the message to be pushed from a server to the browser, and the Notifications API is what allows the message to be displayed, once it gets to the browser. But notice that we can't push notifications from our server directly to the user's browser.

What is UI in angular?

Mobile Angular UI is an open-source framework for developing hybrid mobile apps. Mobile Angular UI makes use of Twitter Bootstrap and AngularJS that helps to create attractive HTML5 hybrid mobile and desktop apps.

What are notifications in angular explain its types?

success —Indicates a successfully completed action. info —Provides neutral information about a process or an action. error —Informs the user about an erroneous outcome from a process or an action. warning —Warns against the occurrence of possible issues.


1 Answers

My suggestion is don't create a one on your own. Use existing models like toastr or something like below. http://beletsky.net/ng-notifications-bar/

like image 121
Madura Pradeep Avatar answered Oct 16 '22 08:10

Madura Pradeep