Angular-strap如何防止点击事件传播到datepicker元素
Angular-strap how to prevent click event propagation to datepicker element
我使用 angular-strap 库来添加日期选择器元素。输入元素在一行中,当我点击行时,我改变了它的颜色。现在,当我使用 class 日期选择器或其他子 table 行单击 div 时,事件被触发。我需要阻止它。我该怎么办?
<table class='css_table'>
<thead class='css_thead'>
<tr class='css_tr'>
<th class='css_th'>Data</th>
</tr>
</thead>
<tbody class='css_tbody' ng-repeat='home in village'>
<tr ng-click='select(home)' ng-class="{'selected':home.isSelected}" >
<td class='css_td'>
<input type="text" ng-model="selectedDate" name="date" ng-click='$event.stopPropagation()' bs-datepicker>
</td>
</tr>
</tbody>
</table>
$scope.select = function(home){
if(home.isSelected == undefined){
home.isSelected = true;
}else{
home.isSelected = !home.isSelected;
}
}
这段代码应该可以工作。
<div ng-click="parentHandler()">
<div ng-click="childHandler(); $event.stopPropagation()"></div>
</div>
我使用 angular-strap 库来添加日期选择器元素。输入元素在一行中,当我点击行时,我改变了它的颜色。现在,当我使用 class 日期选择器或其他子 table 行单击 div 时,事件被触发。我需要阻止它。我该怎么办?
<table class='css_table'>
<thead class='css_thead'>
<tr class='css_tr'>
<th class='css_th'>Data</th>
</tr>
</thead>
<tbody class='css_tbody' ng-repeat='home in village'>
<tr ng-click='select(home)' ng-class="{'selected':home.isSelected}" >
<td class='css_td'>
<input type="text" ng-model="selectedDate" name="date" ng-click='$event.stopPropagation()' bs-datepicker>
</td>
</tr>
</tbody>
</table>
$scope.select = function(home){
if(home.isSelected == undefined){
home.isSelected = true;
}else{
home.isSelected = !home.isSelected;
}
}
这段代码应该可以工作。
<div ng-click="parentHandler()">
<div ng-click="childHandler(); $event.stopPropagation()"></div>
</div>