<div ng-app="myApp">
<div ng-controller="myctrl">
<div test>the value is: {{testmodel}}</div>
<br>
<input type="text" ng-model="testmodel">
</div>
</div>
....
link: function(scope, elm, attrs) {
var standardText = elm.text();
elm.html('something');
$timeout(function() {
console.log(standardText);
elm.html('').append($compile('<span>' + standardText + '</span>')(scope.$parent));
}, 2000);
}
Wait 2 secs, see the content of directive change to a binding. In Firefox, everything works. In IE it works, but it throws a lot of errors in the console.
(Don't worry about what I'm doing here, I just made a small example showing the issue)
A fiddle with a trivial example: http://jsfiddle.net/1t4crp6e/
Wait 2 secs, see the content of directive change to a binding. In Firefox, everything works. In IE it works, but it throws a lot of errors in the console.
(Don't worry about what I'm doing here, I just made a small example showing the issue)
However, most of my tries of actually writing this worked in all browsers except IE. For instance, if I remove the span in the compile, and instead of elm.text() use elm.contents().
http://jsfiddle.net/1t4crp6e/1/ Only changed line 13 and 19 in the js, breaks horribly in IE. It's almost impossible to compile stuff in IE.
Am I doing something wrong? And any workarounds?