I am trying to find a way to watch for a changing value of a property in an object I am scoping my directive to and I'm unable to figure out what I'm doing wrong here.
Here is my directive code:
.directive('selectService', [function() {
return {
restrict: 'EA',
scope: {
distribution: '='
},
link: function(scope, element, attrs) {
scope.$watch(scope.distribution.name, function(newValue) {
console.log("Changed to " + newValue);
});
So say distribution at the time this gets run is something like this:
{ name: '', type: 'all' ... }
I want to $watch for when the property 'name' changes to have a value so that I can enable a select menu in my directive. Everything I've done seems to not work. Any help is appreciated.