Angular Directives In $http Response
Angular 1.5 My $http data service returns html encoded text with directives too, like ng-click in the text. I need to display the html and have the ng-click directives get activate
Solution 1:
Use this Directive also with your code. to bind html element in directive use complie. it will work..
.directive('compile', ['$compile', function ($compile) {
returnfunction(scope, element, attrs) {
scope.$watch(
function(scope) {
return scope.$eval(attrs.compile);
},
function(value) {
element.html(value);
$compile(element.contents())(scope);
}
);
};
}])
Solution 2:
I added the Directive Suresh included and changed the HTML to look like this, it works now. (add 'compile' to the binding element)
<divclass="mt10"ng-repeat="row in aqdas.Paragraphs"ng-cloak><spancompileng-bind-html="TrustDangerousSnippet(row.Text)" >
{{row.Text}}
</span></div>
Post a Comment for "Angular Directives In $http Response"