With AngularJS, it's possible to use the services feature to achieve the same thing, but with encapsulation. This is because services are a singleton, meaning the same instance of an object can be shared across all AngularJS code in the same app.
Example:
angular.module('someModule', [ ]).factory( 'AppState', function() { function SomeClass(){ // what you want as global variables and functions to access them here } var instance = new SomeClass(); return instance; }); |
No comments:
Post a Comment