How to create this global constant to be shared among controllers in Angularjs?
问题 Suppose I want to make this a variable a constant to be shared among controllers in Angularjs; $webroot = "localhost/webroot/app" After some investigation, it seems services are the way to do. But what is the best way? Do I use a factory, service, value or something else? The services.js from angularjs-master-seed is below; angular.module('myApp.services', []).value('version', '0.1'); How do I modify it to have a constant $webroot that is sharable among controllers? Can I do the following?