Reputation: 207
I am using ngRoute to navigate to different pages from a main login page (let's call it index.html
). The routing is done on its main js file. I have a problem when I am trying to use a .run
block in a certain page (named home.html
and which has the corresponding home.js
, through which .run
is being executed) I route to from the main page. Since all the js files are listed in that main index.html
file, it runs all of them while loading that page. As a result, it also executes the app.run
, which I only want to execute when loading home.html
.
It seems that I cannot move the listing of home.js
from index.html
to home.html
, it just does not read it. I am assuming that all the js files of the routed pages must be listed only in the main html file?
So, considering all this, my question is how do I manage to execute .run
for a page I am routing to, but only to that page and not the main routing page?
Upvotes: 0
Views: 36
Reputation: 886
App Run will always run when the application starts up. Doing things like restricting access should be handled in the controller or where you define your routing rules.
Upvotes: 1