JSFiddle - React, Tailwind, and code Playground
HTML
<div ng-app="myapp" ng-controller="someController">
<ol>
<li>{{foo}}</li>
<li>{{bar}}</li>
<li>{{baz}}</li>
</ol>
</div>
JavaScript
var app = angular.module("myapp",[]);
// define a value
app.value('myThing', 'weee');
// use it in a service
app.factory('myService', ['myThing', function(myThing, myOtherThing){
var myLocalOtherThing = myOtherThing || "some default";
return {
whatsMyThing: function() {
return myThing; //weee
},
whatsMyOtherThing: function() {
return myOtherThing;
},
whatsMyOtherThingWithDefault: function() {
return myLocalOtherThing;
}
}
}]);
// use it in a controller
app.controller('someController', function($scope, myService) {
$scope.foo = myService.whatsMyThing(); //weee
$scope.bar = myService.whatsMyOtherThing(); //""
$scope.baz = myService.whatsMyOtherThingWithDefault(); //some default
});