How to parse html tags inside a string in angular js

in the controller I have a say $ scope.question variable.

$scope.question = "Hi this is <br/> book"; 

The html page uses this variable, for example {{question}}.

 <div class="question"> 1. {{question}} </div> 

I need output with line break ... But instead, it displays as a string ... how to parse html tags.

+7
angularjs
source share
1 answer

You must use the ng-bind-html directive. To use this, you need to:

 //1. given .controller('AppController', [ function() { $scope.SomeHtml = '<b>some html</b>'; //2. use ng-bind <div ng-bind-html="SomeHtml"></div> 

Check out the demo from the official AngularJS documentation at plnkr.co .

+10
source share

All Articles