In my directive, there is a function called "myFunction()", and in the template, I have a button. When the button is clicked, I want to execute the function without using ng-click for specific reasons. Instead, I am looking to assign a class to the button within the directive itself, bypassing the controller. It may seem unconventional, but there are valid justifications for this approach.
app.directive('validate', function ($timeout) {
return {
restrict: 'AE',
require: 'ngModel',
link: function (scope, element, attrs, ngModel) {
if (!ngModel){
return;
}
scope.directive_function= function(){
}
ngModel.$parsers.push(function(val){
})
function myFunction(){
alert("clicked");
}
}
};
});