Ram*_*feh 11 javascript html5 twitter-bootstrap angularjs
我有以下代码:
<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>
Run Code Online (Sandbox Code Playgroud)
当我点击OpenPopup时,go()方法也会触发,我怎么能这样做,如果我点击弹出窗口就会触发弹出窗口?
小智 32
这个执行因为你<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>
Run Code Online (Sandbox Code Playgroud)