我正在将当前使用 Angular 1 框架的页面重写为 polymer 1(或 2)。我不知道 polymer 中 ng-repeat 的等价物是什么。这就是我现在在 Angular 1 中所拥有的。
<div class="consultant" ng-repeat="consultant in consultants | limitTo:i">
<p>{{consultant.displayName}}</p>
<p ng-if="consultant.phoneNumber != undefined" >☎ {{consultant.phoneNumber}}</p>
<br ng-if="consultant.phoneNumber == undefined" />
<p class="email" ng-if="consultant.email != undefined" ><span class="icon-envelope"></span><a href="mailto:{{consultant.email}}"> {{consultant.email}}</a></p>
<br ng-if="consultant.email == undefined" />
</div>
最佳答案
您正在寻找的是dom-repeat
可能dom-if
在您的情况下,这可能看起来像这样:
<template is="dom-repeat" items="[[consultants]]" as="consultant">
<div class="consultant">
<p>[[consultant.displayname]]</p>
<template is="dom-if" if="[[consultant.phoneNumber]]">
<p>☎ [[consultant.phoneNumber]]</p>
</template>
<template is="dom-if" if="[[!consultant.phoneNumber]]"><br></template>
<template is="dom-if" if="[[consultant.email]]">
<p class="email">
<span class="icon-envelope"></span>
<a href="mailto:[[consultant.email]]">[[consultant.email]]</a>
</p>
</template>
<template is="dom-if" if="[[!consultant.email]]"><br></template>
</div>
</template>
关于javascript - 相当于 ng 重复的 polymer ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46552086/