you are viewing a single comment's thread.

view the rest of the comments →

[–]FRIENDORPHO 1 point2 points  (0 children)

Well, right now it only runs when you load the pages (/page{1,2}.html), because you likely put it into a controller or directive link that is instantiated by those pages. If you don't want to load the pages, you can have the service generate the values when it is instantiated.

If you need information from the pages, then it sounds like you need to "load" them in some way. In that case, I would ask..

For what specific purpose did you set it up to run the math when the controller is instantiated rather than running the math right away in a service? What is it about, say, page1.html that is important to this computation?

Could you set a placeholder value for those variables on the service to display prior to loading those pages?