How to display   or any raw html in angular data?

后端 未结 5 1574
后悔当初
后悔当初 2020-12-09 08:29

How can I display   as space not as string. Is there raw filter like in twig?

{{item}}
$scope.item
5条回答
  •  囚心锁ツ
    2020-12-09 09:08

    It can be easily done by using ngBindHtml

    For Angular above 1.2.x version:

    use ng-bind-html

    Working Demo

    html

    script

    var app = angular.module('myApp', ['ngSanitize']);
    app.controller('Controller', function ($scope, $sce) {
       $scope.item = 'What Is Your Name?';
    });
    

    For Angular 1.0.x version:

    Working Demo

    use ng-bind-html-unsafe

    html

    script

    var app = angular.module('myApp', []);
    app.controller('Controller', function ($scope) {
       $scope.item = 'What Is Your Name?';
    });
    

提交回复
热议问题