I'm using typescirpt in Angular.
I've created a directive that is just a div containing text and a close button with a class name 'block-close'
I need to add an click function to the close button.
How do I add a click event to button that is inside the directive.
I've tried things like
angular.element('.block-close').on('click', function(){
alert('here');
});
angular.element(document).find('.block-close').on('click', function(){
alert('here');
});
(()=>{
class MyDirective implements ng.IDirective{
public restrict = 'E';
public scope = {};
public controller = 'MyController';
public controllerAs = 'myCtrl';
public bindToController = true;
public templateUrl = "mysite.html";
constructor(){
}
link = (scope, element, attrs) => {
angular.element('.block-close').on('click', function(){
alert('here');
});
};
}
angular.module('myMod').directive('myDirective', ()=> new MyDirective());
})();