How can I display
as space not as string. Is there raw
filter like in twig?
JavaScript
x
4
1
<div>{{item}}</div>
2
3
$scope.item = ' ';
4
But the result is escaped &nbsp;
. I need this because ' '
have height of 0.
Advertisement
Answer
It can be easily done by using ngBindHtml
For Angular above 1.2.x version:
use ng-bind-html
html
JavaScript
1
4
1
<div ng-app='myApp' ng-controller="Controller">
2
<div ng-bind-html="item"></div>
3
</div>
4
script
JavaScript
1
5
1
var app = angular.module('myApp', ['ngSanitize']);
2
app.controller('Controller', function ($scope, $sce) {
3
$scope.item = 'What Is Your Name?';
4
});
5
For Angular 1.0.x version:
use ng-bind-html-unsafe
html
JavaScript
1
4
1
<div ng-app='myApp' ng-controller="Controller">
2
<div ng-bind-html-unsafe="item"></div>
3
</div>
4
script
JavaScript
1
5
1
var app = angular.module('myApp', []);
2
app.controller('Controller', function ($scope) {
3
$scope.item = 'What Is Your Name?';
4
});
5