我有以下代码
<uib-accordion close-others="true" class="my-table">
<div class="accordion-group">
<div class="column-header accordion-heading">
<div class="accordion-toggle">
<div class="accordion-cell">column1</div>
<div class="accordion-cell">column2</div>
<div class="accordion-cell">Remove</div>
</div>
</div>
</div>
<uib-accordion-group ng-repeat="row in parentRows">
<uib-accordion-heading class="accordion-heading">
<div ng-click="loadAccordionContent(row)" class="accordion-row">
<div class="accordion-cell">{{row.col1Val }}</div>
<div class="accordion-cell">{{row.col2Val }}</div>
<div class="accordion-cell">
<button type="button" ng-click="removeRow(row)"
class="btn btn-sm cat-remove-button">
Remove
<i class="glyphicon glyphicon-remove">
</i>
</button>
</div>
</div>
</uib-accordion-heading>
<div>Some dynamic content</div>
</uib-accordion-group>
</uib-accordion>
当我点击按钮时,此代码将重新路由到我应用的主页。那为什么会这样?我希望它调用removeRow(row)来删除该行并更新parentRows。
答案 0 :(得分:0)
更改
removeRow(row)
到
removeRow(row, $event)
并在我的函数开头添加以下代码解决了这个问题
if ($event) {
$event.stopPropagation();
$event.preventDefault();
}