angularjs - ng-click ons-list-item 内的 span 不起作用

标签 angularjs onsen-ui

我有一个带有列表项和图标的ons-list,当有人单击列表项时,它应该转到屏幕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()"

Here更深入地解释了事件冒泡和捕获背后的魔力

关于angularjs - ng-click ons-list-item 内的 span 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35646311/

相关文章:

javascript - Ajax api 调用总是失败

AngularJS $location 在散列之前获取路径

javascript - 在 AngularJS 中更改路线时如何防止 View 重绘

angularjs - 如何在ng-click事件中调用http请求?

javascript - 温泉用户界面 : Contact Us Form Submission

jquery - 根据产品可用性禁用按钮

javascript - FullCalendar 独特的自定义每周 View

javascript - AngularJS 奇怪的行为,NG-INCLUDE 导致整个页面重新加载

javascript - 温泉 UI 导航错误 : You can not supply no "ons-page" element to "ons-navigator" when back to first page

javascript - 显示传入数据流 - 无法访问未定义的属性