I made a directive that I insert it in the div father to restrict some things (such restrictions that I do not put in the example), but I also want to listen when click in the second element only in the second element, how can I listen when click ?
Note: I just want to insert the
directive into the parent div.
angular
.module('MyApp', [])
.directive(
'clickMe',
function() {
return {
link: function(scope, element) {
element.on('click', function() {
console.log('click');
});
},
};
}
);
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="MyApp">
<div click-me>
clickeame
<div id="one">
click 2
</div>
</div>
</div>