我正在将当前使用Angular 1框架的页面重写为聚合物1(或2)。我不知道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>
答案 0 :(得分:2)
您要找的是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>