JSFiddle - React, Tailwind, and code Playground
by RajamohanShilpa A
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.8/angular.js"></script>
JavaScript
angular.module('myApp',[]).controller('myCtrl1', function($scope,myFac,mySer){
$scope.factoryValue1 = myFac.get();
myFac.set('Test Factory from Controller');
$scope.factoryValue2 = myFac.get();
$scope.serviceValue1 = mySer.get();
mySer.set('Test Service from Controller');
$scope.serviceValue2 = mySer.get();
}).factory('myFac', function(){
var returnObj = {};
returnObj.value = 'Test Factory';
returnObj.set = function(value){
returnObj.value = value;
};
returnObj.get = function() {
return returnObj.value;
};
return returnObj;
}).service('mySer', function(){
this.value = 'Test Service';
this.set = function(value){
this.value = value;
};
this.get = function() {
return returnObj.value;
};
});