AngularJS - Bootstrapping data into a service on page load -


In an angular application, I'm trying to use a custom service to catch the main data of the app, "Items" However, I want to boot on the data on the initial page load to get it to avoid a different Ajax request on the server.

  app.factory ('items', function) var itemsService = {}, item = [] item; Service.list = function () {return item;} item itemservice = add   

and on the backend I am using node.js + expressjs + jade, so I use data In the page I'm injected:

 ! {JSON.stringify (item)}    

From the server your bootstrap data is in the global form Keep Javascript Variable

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -