我有ng-repeat的指令,并希望传递值从外部迭代。
喜欢
<mydirective list="array" repeatstring="item in list | firstfilter | secondfilter |orderBy:value"></mydirective>
<mydirective list="array" repeatstring="item in list | thirdfilter | secondfilter |orderBy:value"></mydirective>
<mydirective list="array" repeatstring="item in list | fourthfilter | secondfilter |orderBy:value"></mydirective>
和指令看起来像
<div ng-repeat="{{repeatstring}}">
<!--repeat insides -->
</div>
我尝试过使用不同绑定和ng-init的不同变体,但它接缝显示的唯一结果是eather表达错误或非渲染ng-repeat。 也许有人用角度
拉了这个把戏jsFiddle:http://jsfiddle.net/Q37gC/2/
答案 0 :(得分:0)
我害怕你不能! more details
因此,请跳过自定义指令,并将custom filter与ng-repeat
一起使用
ng-repeat="item in list | myFilter"
myApp.filter('myFilter', function () {
return function (input) {
// use your logic
};
});