2013-09-28 107 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