javascript - Using instantiated object reference within the controller -


i'm trying figure out how use 1 javascript object instantiation across multiple controllers in angularjs. try envisage following scenario:

var objtemplate = new templateobject(); objtemplate.init();  app.controller('homecontroller', function($scope) {      objtemplate.slidepage();  }); 

obviously objtemplate.initialise(); doesn't work within controller , i'm not quite sure how it.

edit:

thanks answer @atrix - looks way forward create new service , move of functionality javascript object - use service perform these operations.

you can try using factory in order instantiate object once , access controllers.

for more details factory , service , examples check @matys84pl & @justgoscha answers about services & factory


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -