2013-09-28 156 views

回答

1

link功能爲sel指令的每個實例只運行一次,所以它呈現arr.name值一次。爲了使其意識到未來的變化,你可以使用一個$watch

link: function(scope, elm, attr){ 
    scope.$watch('arr.name', function() { 
    elm.text(scope.arr.name) 
    }); 
} 

Plunker here

你可以在$rootScope documentation找到更多的信息。

+0

完美!謝謝,我將重新讀取根作用域。我之前曾試過手錶,但一直在使用'scope.arr'。再次感謝您的幫助。 – tobsai