Sharing Top Content from the Angular-sphere.

init function won’t stop running • /r/angularjs

  • init function won’t stop running ( self.angularjs )
  • So I have an init function that runs once the document is loaded, but the function pulls data from the backend (Django) which is completed once the template is re-rendered again.
  • So basically the init function get run every time the template gets rendered, but I only want it to run once per template rendering
  • you could use a resolve to get the initial data and remove the data retrieval from the init function or use an isInit bool to prevent multiple retrievals or just check if the data is undef or null before retrieval
  • If you’d put that function in a controller, it would run once the document and controller is loaded and pass data to the view.

So I have an init function that runs once the document is loaded, but the function pulls data from the backend (Django) which is completed once…

@Beepop_Agency: init function won’t stop running:

So I have an init function that runs once the document is loaded, but the function pulls data from the backend (Django) which is completed once the template is re-rendered again. This then causes an infinite loop as whenever the document loads, the init function gets executed again. How can I avoid this?

init function won’t stop running • /r/angularjs

Comments are closed, but trackbacks and pingbacks are open.