I am newbie of AngularJS. I want NOT to escape HTML tag, so
- include angular-sanitize.js
- write the code below:
<!-- <div>{{article.content}}</div> --> <div ng-bind-html="{{article.content}}"></div> But nothing is being rendered.
You don't need the braces:
<div ng-bind-html="article.content"></div> you also need to make sure angular knows that it's safe in your controller:
$sce.trustAsHtml($scope.article.content); $sce is needed if you don't link sources outside the application? The other answer's plunker seems to work fine without.I think this will be help you.
var app = angular.module('app', ['ngSanitize']); app.controller('appCtrl', ['$scope', '$sce', ctrl]); function ctrl($scope, $sce) { $scope.getContent = function() { return "shohel rana"; }; } <body ng-controller="appCtrl"> <h1>Hello Plunker!</h1> <div ng-bind-html="getContent()"></div> </body>
angular.module("myapp", ["ngSanitize"])?