ng 单击列表项内的 span 不起作用



我有一个带有列表项和图标的列表,当有人单击列表项时,它应该转到屏幕 A,当我单击图标时,它应该转到屏幕 B,但问题是当我们单击图标时 ng 单击冲突,技术上列表项也被单击。请参阅下面的代码。

<div ng-controller="getUserContacts">
<ons-list-header>Select Contact</ons-list-header>
<ons-list style="margin: -1px 0">   
    <div ng-show="loading" class="loading"><img src="img/loading.gif" height="50px" width="50px"></div>
    <ons-list-item modifier="" class="list-item" ng-repeat="x in contacts track by $index" style="margin-left: 10px;" ng-click="setcontact(x); page.pushPage('sendmoney2.html', {animation: 'slide'});">                    
        <ons-row>                           
            <ons-col width="52px" style="padding: 10px 0 0 0;">
                <img src="img/red.png" height="42px" width="42px"/>
            </ons-col>
            <ons-col>
                <header>
                    <span class="item-title">{{x.name}}</span>
                    <span class="list-item-note-sendmoney1"  ng-click="page.pushPage('editContact.html', {animation: 'slide'});"><ons-icon icon="ion-ios-information-outline" size="28px"></ons-icon></span>
                </header>
                <p class="swipe-item-desc">{{x.phone}}</p>
            </ons-col>                              
        </ons-row>                      
    </ons-list-item>
</ons-list>
</div>

谢谢。

只需停止事件传播,您应该没事。将$event.stopPropagation()添加到您的第二次ng-click中,如下所示:

ng-click="page.pushPage('editContact.html', {animation: 'slide'});$event.stopPropagation()"

以下是关于事件冒泡和捕获背后的魔力的更深入的解释。

最新更新