Angular-strap如何防止点击事件传播到datepicker元素

时间:2015-01-29 11:57:50

标签: angularjs javascript-events angular-strap

我使用angular-strap库添加datepicker元素。输入元素是一行,当我点击行时,我改变它的颜色。现在当我点击带有类datepicker或其他子表行的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;
    }
}

1 个答案:

答案 0 :(得分:0)

这段代码应该有用。

<div ng-click="parentHandler()">
    <div ng-click="childHandler(); $event.stopPropagation()"></div>
</div>