I have a service where I pass some data on click what works great, but now I wanna pull that data from the service and add it to a scope in another controller and just log everytime there is something added with the $watch function.
My service:
app.service('infoService', function() {
var currentInfo = [];
return this.method = function(data){
return currentInfo = data;
};
});
Where I try to pull the data
app.controller('clickController', function($scope, infoService) {
$scope.data = infoService.method();
$scope.$watch('data', function(newVal, oldVal) {
console.log(newVal, oldVal);
});
});
The only thing I currently see the last hour are errors and errors.