【发布时间】:2016-02-08 14:14:09
【问题描述】:
我正在寻找一种解决方案,让我可以根据设置的变量使用ng-repeat 或collection-repeat 作为重复列表。
我了解有以下几种可能:
- 使用动态模板并在运行时加载正确的模板
- 可能使用
ng-attr
我想避免 1,因为我不想要两个模板 - 我必须不断更新两个模板中的代码。
就 2 而言,我似乎无法将其应用于传递参数的指令 (Angular - Use attribute directive conditionally)
我想要实现的是:
//if $root.platformOS == "desktop"
<ion-item ng-repeat="event in events| filter:search.text" item-height="event.Event.height" id="item-{{$index}}">
//if $root.platformOS != "desktop"
<ion-item collection-repeat="event in events| filter:search.text" item-height="event.Event.height" id="item-{{$index}}">
谢谢。
【问题讨论】:
标签: angularjs angularjs-directive