I have a service (Utilities) that returns a promise object:
.service('Utilities',function($q){
var self = this;
var deferred = $q.defer();
..... function thats calls self.filteredDataGlobal.....
self.getFilteredData = function(){
if(self.filteredDataGlobal){
deferred.resolve(self.filteredDataGlobal);
}
return deferred.promise;
};
});
In my controller I call the promise object when it's ready, which works...
.controller('myController', function($scope, Utilities) {
var self = this;
Utilities.getFilteredData().then(function(data){
self.filteredData = data;
});
//watch for when self.filteredDataGlobal changes on the Utilities service
$scope.$watch(self.filteredData, function (newVal, oldVal) {
console.log(newVal, oldVal);
self.filteredData = newVal;
});
});
...but I'm trying to "watch" for when self.filteredDataGlobal changes on the Utilities service. Right now this is logging undefined, undefined