javascript - Passing variables betweencontrollers in angular js -
i new angular js , services please bear basic question. please read comment inside code understand need.
.controller('ctrlr1', function($scope, myservice) { var = "abc"; }) .controller('ctrl2', function ($scope, myservice) { // how value of }) .service('myservice', function() { //what goes here? });
thanks in advance
basic sharing angular
services
.controller('ctrlr1', function($scope, myservice) { var = "abc"; var b = 123; myservice.mydata = a; myservice.mydatab = b; }) .controller('ctrl2', function ($scope, myservice) { // how value of console.log(myservice.mydata); console.log(myservice.mydatab); }) .service('myservice', function() { //what goes here? this.mydata = ''; this.mydatab = 0; });
Comments
Post a Comment