Loading data when entering the root state

I would like to load data or do some calculations when the application enters root state, any ideas how to implement it?

+4
source share
1 answer

I'm not sure about your problem because the controllers have no states, so I assume you are talking about routes.

If you want to load data when entering the root state, this function has not yet been implemented, but it will probably be later.

Take a look at this problem: Controller instances do not have root status available in connectOutlets. I think this is exactly your problem.

Before you implement this function, you can still:

  • Loading data into the ApplicationController#init method
  • Add a route containing everything else (root.all) and load the data into the connectOutlets routes connectOutlets method (I don't like this solution)
  • Complies with the applicationController property of the router by doing this (see this JSFiddle ):

     App.Router = Em.Router.extend({ loadData: function() { // load data here }.observes('applicationController'), }); 
+2
source

Source: https://habr.com/ru/post/1438613/


All Articles