Imagine I need to create a constant variable that can be shared between controllers in Angularjs;
$webroot = "localhost/webroot/app"
After some research, it appears that services are the recommended approach. But which one should I use? Should I implement a factory, service, value, or something else?
The angularjs-master-seed's services.js is shown below;
angular.module('myApp.services', []).value('version', '0.1');
How can I update it to include a constant $webroot that can be accessed by multiple controllers?
Would the following code work?
angular.module('myApp.services', [])
.value('version', '0.1')
.constant('webroot','localhost/webroot/app');
If this implementation is correct, how would I call it in the controller?