I am encountering an issue with triggering a click
event in my Angular app using code similar to the example below. Can anyone help me understand why the event is not being triggered?
var app = angular.module("myApp", [])
app.directive('myTop',function($compile) {
return {
restrict: 'E',
template: '<div></div>',
replace: true,
link: function (scope, element) {
var childElement = '<button ng-click="clickFunc()">CLICK</button>';
element.append(childElement);
$compile(childElement)(scope);
scope.clickFunc = function () {
alert('Hello, world!');
};
}
}
})