return {
restrict: 'EA',
link: function (scope, element, attr) {
element.bind('mouseenter', function() {
this.after("<p style='position: absolute;'><img src=" + this.src + " /></p>")
});
}
}
For example, as shown above, using jquery’s after method, this p is displayed as a string on the page. How can it be parsed directly?
Use $compile
Written a small online demo
http://embed.plnkr.co/egEOkZv...
This is caused by the quotation marks in the title of the question
Obviously the url here is missing a quotation mark. The src of img should be wrapped in quotation marks. You can add single quotation marks on both sides
Your string on the page is also src without quotes