Answer the question
In order to leave comments, you need to log in
Directive and DOM event handling in AngularJS?
There is a directive that has a mousedown event
function evClick() {
return {
restrict: "AE",
link: function (scope, element) {
element.bind('mousedown', function (event) {
console.log("mousedown");
});
}
};
}
angular.element(document.getElementById('foo')).append("<h2 ev-click>add element</h2>");
Answer the question
In order to leave comments, you need to log in
Angular does not know how to parse HTML on every change by the user. If you need to dynamically generate templates, then you should use the $compile service:
Example on plnkr
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question