【发布时间】:2012-10-19 14:02:14
【问题描述】:
我不明白如何在链接函数中同时观察多个属性,所以我创建了一个包含所有参数的对象并观察它。但我注意到链接函数中的属性是字符串而不是对象,所以我使用的是 angular.fromJson(val)。
All the example I found just use one parameter
您能解释一下如何查看多个属性吗?
谢谢
编辑: 我不能使用 attrs 参数,因为我需要绑定属性——即它们需要插值。例如
<ul class="thumbnails">
<li class="span3" ng-repeat="image in currentSizeInfo.images" >
<upload-file info = "{{getInfo($index)}}" foo="foo$index" ></upload-file>
</li>
</ul>
我认为我必须使用 $watch
link:function (scope, element, attrs ) {
scope.$watch('info', function (val) {
// if info is and foo is .... do all the stuff
})
}
【问题讨论】:
标签: javascript angularjs angularjs-directive