Html AngularJS-对ng repeat中的某些项目禁用ng href
我正在使用ng repeat创建一个事件列表,我希望每个事件都链接到另一个位置,我已经成功地完成了。然而,这个ng href也被应用于列表分隔符,我宁愿避免使用它。如果条件为真,是否有任何方法可以有条件地应用ng href?我考虑改用ng click并让它处理URL,但这样事件列表项就不再像链接了 这是迄今为止我的HTMLHtml AngularJS-对ng repeat中的某些项目禁用ng href,html,angularjs,ionic-framework,Html,Angularjs,Ionic Framework,我正在使用ng repeat创建一个事件列表,我希望每个事件都链接到另一个位置,我已经成功地完成了。然而,这个ng href也被应用于列表分隔符,我宁愿避免使用它。如果条件为真,是否有任何方法可以有条件地应用ng href?我考虑改用ng click并让它处理URL,但这样事件列表项就不再像链接了 这是迄今为止我的HTML <ion-item class="item" ng-class="{'item-divider': isDivider(event), 'item-icon-right
<ion-item class="item" ng-class="{'item-divider': isDivider(event), 'item-icon-right': !isDivider(event)}" ng-repeat="event in events" ng-href="#/app/{{channel}}/{{event.id}}">
<h2>{{event.title}}</h2>
<p ng-if="valid(event.start_date)">{{showDate(event.start_date)}}</p>
<i ng-if="!isDivider(event)" class="icon ion-chevron-right"></i>
</ion-item>
简短回答:没有 你需要这样的东西:
<ion-item class="item" ng-class="{'item-divider': isDivider(event), 'item-icon-right': !isDivider(event)}" ng-repeat="event in events">
<div ng-if="!isDivider(event)" ng-href="#/app/{{channel}}/{{event.id}}">
<h2>{{event.title}}</h2>
<p ng-if="valid(event.start_date)">{{showDate(event.start_date)}}</p>
<i class="icon ion-chevron-right"></i>
</div>
<div ng-if="isDivider(event)">
<h2>{{event.title}}</h2>
<p ng-if="valid(event.start_date)">{{showDate(event.start_date)}}</p>
</div>
</ion-item>
这样,分隔符既不会表现也不会看起来像链接。简短回答:不,没有 你需要这样的东西:
<ion-item class="item" ng-class="{'item-divider': isDivider(event), 'item-icon-right': !isDivider(event)}" ng-repeat="event in events">
<div ng-if="!isDivider(event)" ng-href="#/app/{{channel}}/{{event.id}}">
<h2>{{event.title}}</h2>
<p ng-if="valid(event.start_date)">{{showDate(event.start_date)}}</p>
<i class="icon ion-chevron-right"></i>
</div>
<div ng-if="isDivider(event)">
<h2>{{event.title}}</h2>
<p ng-if="valid(event.start_date)">{{showDate(event.start_date)}}</p>
</div>
</ion-item>
这样,分隔符既不会表现也不会看起来像链接。简短回答:不,没有 你需要这样的东西:
<ion-item class="item" ng-class="{'item-divider': isDivider(event), 'item-icon-right': !isDivider(event)}" ng-repeat="event in events">
<div ng-if="!isDivider(event)" ng-href="#/app/{{channel}}/{{event.id}}">
<h2>{{event.title}}</h2>
<p ng-if="valid(event.start_date)">{{showDate(event.start_date)}}</p>
<i class="icon ion-chevron-right"></i>
</div>
<div ng-if="isDivider(event)">
<h2>{{event.title}}</h2>
<p ng-if="valid(event.start_date)">{{showDate(event.start_date)}}</p>
</div>
</ion-item>
这样,分隔符既不会表现也不会看起来像链接。简短回答:不,没有 你需要这样的东西:
<ion-item class="item" ng-class="{'item-divider': isDivider(event), 'item-icon-right': !isDivider(event)}" ng-repeat="event in events">
<div ng-if="!isDivider(event)" ng-href="#/app/{{channel}}/{{event.id}}">
<h2>{{event.title}}</h2>
<p ng-if="valid(event.start_date)">{{showDate(event.start_date)}}</p>
<i class="icon ion-chevron-right"></i>
</div>
<div ng-if="isDivider(event)">
<h2>{{event.title}}</h2>
<p ng-if="valid(event.start_date)">{{showDate(event.start_date)}}</p>
</div>
</ion-item>
这样,分隔符既不会表现也不会看起来像链接。meta:ionic-ion-item-conditional href 这是我的解决方案,仅当列表项具有子元素时才有条件地使用a href 请注意,如果设置了href,则ion项只是一个可单击的元素,因此不需要修改css类 {{item.index}。{{item.name} {{item.index}。{{item.name}
meta:离子离子项条件href 这是我的解决方案,仅当列表项具有子元素时才有条件地使用a href 请注意,如果设置了href,则ion项只是一个可单击的元素,因此不需要修改css类 {{item.index}。{{item.name} {{item.index}。{{item.name}
meta:离子离子项条件href 这是我的解决方案,仅当列表项具有子元素时才有条件地使用a href 请注意,如果设置了href,则ion项只是一个可单击的元素,因此不需要修改css类 {{item.index}。{{item.name} {{item.index}。{{item.name}
meta:离子离子项条件href 这是我的解决方案,仅当列表项具有子元素时才有条件地使用a href 请注意,如果设置了href,则ion项只是一个可单击的元素,因此不需要修改css类 {{item.index}。{{item.name} {{item.index}。{{item.name} ng click=$event.preventDefault在分隔符上。您可以使用ng click;只需使用CSS将事件列表项设置为链接样式:ng click=$event.preventDefault在分隔符上。您可以使用ng click;只需使用CSS将事件列表项设置为链接样式:ng click=$event.preventDefault在分隔符上。您可以使用ng click;只需使用CSS将事件列表项设置为链接样式:ng click=$event.preventDefault在分隔符上。您可以使用ng click;只需使用CSS将事件列表项设置为链接样式: