Skip to content
Advertisement

Angular-strap how to prevent click event propagation to datepicker element

I use angular-strap library to add datepicker element. The input element is in a row, and when I click row, I change it’s color. Now when I click on div with class datepicker, or other child table row the event is trigger. I need to prevent it. How can I do?

    <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;
    }
}

Advertisement

Answer

This piece of code should work.

<div ng-click="parentHandler()">
    <div ng-click="childHandler(); $event.stopPropagation()"></div>
</div>
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement