Code:
<table>
<tr ng-click="function()">
<td id="1"></td>
<td></td>
<tr>
</table>
How to delete click-handler from td with id = 1? Thanks
Code:
<table>
<tr ng-click="function()">
<td id="1"></td>
<td></td>
<tr>
</table>
How to delete click-handler from td with id = 1? Thanks
I'm going to take this to mean that you don't want to fire the click event handler in td id=1, but you do want every other td in that row to still fire it.
ng-click wires up regular javascript event handlers. Since you are listening for the click event on the tr element, you simply have to stop the event from propagating when it fires on a child element to ahiceve this.
It would probably be best written as a directive
app.directive('disableClick', function() {
return function(scope, elem) {
elem.on('click', function(e) {
// e.stopPropagation(); or for IE, window.event.cancelBubble
return false; // My assumption is that jqLite supports this, jQuery definitely does.
});
}
});
HTML
<td disable-click id="1"></td>
The click event will no longer bubble up to the TR.
The proper way to do it, it's in a directive. I found one that it could help you Here you go an example click no bubble
angular.forEach( 'click dblclick mousedown mouseup mouseover mouseout mousemove mouseenter mouseleave'.split(' '),
function(name) {
var directiveName = name.replace('my-' , '');
app.directive( directiveName, ['$parse', function($parse) {
return function(scope, element, attr) {
var fn = $parse(attr[directiveName]);
element.bind(lowercase(name), function(event) {
event.stopPropagation();
scope.$apply(function() {
fn(scope, {$event:event});
});
});
};
}]);
I hope it helps