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
Post a Comment