我有以下代码:
<table class="table"> <tr> <th>Name___</th> </tr> <tr ng-repeat="app in apps" ng-click="go('/editApp/' + plugin.name);"> <td> <span>{{app.name}}</span> </td> <td style="width: 100px;"> <i class="glyphicon glyphicon-pencil" ng-click="openPopup(app)"></i> </td> </tr> </table>
当我点击OpenPopup,还有go()方法触发,我该怎么做,如果我点击弹出窗口,弹出窗口会触发?
解决方法
由于您的< td>嵌套在< tr>中,然后单击首先触发openPopup()
然后点火go().您可以使用$event.stopPropagation()来停止事件传播到< tr>.
尝试
<table class="table"> <tr> <th>Name___</th> </tr> <tr ng-repeat="app in apps" ng-click="go('/editApp/' + plugin.name);"> <td> <span>{{app.name}}</span> </td> <td style="width: 100px;"> <i class="glyphicon glyphicon-pencil" ng-click="openPopup(app);$event.stopPropagation()"></i> </td> </tr> </table>