Angular filter to pass HTML string

2

Hi, how can I do a angular filter, to read a string html , or how do I create a method to read a string html

<div ng-bind-html="item.description"></div>

why when I save text with

he saves it but he shows me the html tags

<div class="des-img_gal-pre" ng-show="item.have_description">
      <div ng-bind-html="item.description"></div>
 </div>
    
asked by Edison Sarmiento 27.03.2018 в 18:57
source

1 answer

1

You could use the directive ngBindHtml .

var app = angular.module("myApp", ['ngSanitize']);
app.controller("myCtrl", function($scope) {
    $scope.myText = "Mi nombre es: <h1>Carlos :)</h1>";
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular-sanitize.js"></script>
<body>

<div ng-app="myApp" ng-controller="myCtrl">

    <p ng-bind-html="myText"></p>

</div>
  

Note: This example includes the " angular-sanitize.js ", which has   Functions to remove potentially dangerous HTML tokens

    
answered by 28.03.2018 в 02:54