javascript - Binding Controller Property containing HTML in AngularJS -
First of all: I'm absolutely new to Angular JS but have worked on MVC projects in other languages.
I try to bind the property with HTML.
This code is:
HTML:
& lt; Div ng-controller = "MyController" & gt; & Lt; P & gt; {{About}} & lt; / P & gt; & Lt; / Div & gt;
js:
.controller ('MyController', ['$ scope', function ($ radius) {$ scope.About = "it is I do not want
now HTML is encoded ( & lt; br / & gt;
I have tried it on & lt; p ng-bind-html = "about" & gt; & lt; / p & gt;
No output came
P>
You need to allow html in your text Which does not by default by angle.
Hard Distinguished escaping (SCE) is a condition in which the enigulers require bindings in some contexts, which is consequently marked as safe to use for that reference. An example of such reference is the user's ng -Bind-HTML-controlled arbitrary HTML is binding. We may get these references as privileged or SCE contexts View in.
& lt; Div ng-controller = "html rhrr" ng-bind-html = "about" & gt; & Lt; / Div & gt; & Lt; Script & gt; Angular.module ("app", []). Controller ("html variable", function ($ radius, $ sce) {$ scope.about = $ sce.trustAsHtml ("This is not me!");}); Angular.bootstrap (document, ["app"]); & Lt; / Script & gt;