javascript - Notify a directive about data receiving -


I have this simple angular command:

  angular. Module ("instructions"). {Link: function (scope, element, ethers) {console.log ("loading directive", scope, element, etter); element.addClass ("hidden", "loading", function ($ rootsecope) {return} ); $ RootScope. $ ("$ RouteChangeStart", function (Event, Next, Current) {element.removeClass ("hidden");}); // How do I get the data in the controller? & Lt; - - }};});  

As you can see, it allows me to show a loading message for displaying the route of the app, like this:

Loading. ..

My problem is that I do not know about notifying the instructions to make it disappear.

We say the route is connected to / list / ListController . When url hits / list / , the controller will load some data and only when this data is received I want to remove the loaded message. There is no direct instruction when the controller's data is distributed, my question remains:

How do I come up with a decent design for this?

In order to simplify the design and to structure it in a way, what do I have to do A 'messaging' service which is defined as part of the angular module. Whenever a path change occurs, it sets its current message to 'Loading ...' 'and when a controller is loading (for example eliminating all Ajax requests), then this A clear () calls on the message

In your instructions (a navbar in my case), you get the latest message from your messaging You can see and change the warning that the latest message Rtn If it is empty, you can delete the message and so forth.

A little more work, I think, but its much more structured and modular in this way. In addition, since the messaging service is central, you want to accept messages from many such modules.


Comments

Popular posts from this blog

c# - NewtonSoft JArray - how to select multiple elements with LINQ -

c# - Process.Kill() returns access denied -

c# - Using the generic type 'System.Collections.Generic.List<T>' requires 1 type arguments -