2013-11-22 24 views
0

我在一個指令鏈接功能

link: function (element, attrs, linker) { 
       return function ($scope, lElement, attrs){ 

        $scope.$watch('hello.message', function() { 
         console.log($scope.hello.message); 
        }); 

       //Id like to just watch he model this bit it wont work 
        $scope.$watch('hello', function() { 
         console.log($scope.hello.message); 
        }); 
       } 
     } 

有人可以解釋爲什麼看只是模型下面的代碼不會工作? 如果我看模型$ .scope.hello指令中的$ watch不會工作 我是否需要在指令選項中包含或設置一些其他屬性?

回答

1

嘗試設置$看第三個參數(objectEquality)爲true

+0

燁那絕對沒有的伎倆,感謝指出了這一點。我一直忽略了第三個參數。 –

相關問題