I'm facing a dilemma. I have created a directive
app.directive('a', function() {
return {
restrict: 'E',
link: function(scope, elem, attrs) {
elem.on('click', function(e){
e.preventDefault();
alert('Hyperlinks not allowed!');
});
}
};
});
and I also have an $http
request to fetch JSON
data for the page
{
"currentNodeName":"Page 1",
"childrenNodes":[
{"id":"3","name":"Page 1-1"},
{"id":"4","name":"Page 1-2"}],
"parentNode":null,
"currentNodeContent":[
{"content":"<p>This is Page1. <a href=\"http://badlink.org/i/dont/want/to/work\">Link</a></p>"}],
"currentNodeId":"1"
}
The content of currentNodeContent
is then loaded into a div
<div id="loadedContent" ng-bind-html="boardCtrl.nodeData.currentNodeContent[0].content"></div>
Now, my question is:
How can I make sure that the <a>
tag in the loaded content functions as a directive?
Thank you.