In my HTML, I am using
to show some text, like this:
<p> {{item.bio}} </p>
And here is the sample of bio object:
"bio": "A<br>B<br>C<br>D<br>E<br>F"
I was expecting that I'll get each and every alphabet in separate lines, but worst thing is when I run my HTML, showing me text as it is written with <br>
tag.
For inserting html in ionic V1 you should use ng-bind-html
directive:
<div ng-bind-html="item.bio"></div>
and for second version
<div [innerHTML]="item.bio"></div>
Evaluates the expression and inserts the resulting HTML into the element in a secure way. Use ngSanitize in your module's dependencies.
Your code would we like:
<p ng-bind-html="item.bio"></p>
For more details read here .
use sanitize
angular.module('sanitizeExample', ['ngSanitize'])
.controller('ExampleController', ['$scope', '$sce', function($scope, $sce) {
$scope.snippet =
'<p style="color:blue">an html\n' +
'<em onmouseover="this.textContent=\'PWN3D!\'">click here</em>\n' +
'snippet</p>';
$scope.deliberatelyTrustDangerousSnippet = function() {
return $sce.trustAsHtml($scope.snippet);
};
}]);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.