I want to access the controller values from service, how can I access it. I am try to access the controller values by using the following code. The code is here JsBin.com
<script>
var app = angular.module('app', [])
.controller("ctrl1",['$scope','svc',function($scope,svc){
$scope.fun1=function(){
svc.service_set();
alert(svc.txt1);
alert(svc.txt2);
}
}])
.controller("ctrl2",['$scope','svc',function($scope,svc){
$scope.fun2=function(){
svc.service_set();
alert(svc.txt1);
alert(svc.txt2);
}
}]).
service("svc",function(){
var svc={};
svc.service_set=function()
{
//I want to access the controller values from here
svc.txt1=ctrl1.c1txt1;
svc.txt2=ctrl2.c2txt1;
}
return svc;
})
;
</script>