1

I am retrieve data from JSON and also retrieve some text content but text content not support p tag. I will show you screen shot for hints.
enter image description here

When we retrieved the Text content then it is showing like this(with p tag). JSON URL:

http://www.json-generator.com/api/json/get/bTRWzhCvuG?indent=2

HTML:

<div ng-controller="chooseProductDescription">
      <div ng-repeat="cat in productDescription">
                <div>{{cat.product.fullDescription}} </div>             
       </div>
</div>

CONTROLLER:

.controller('chooseProductDescription', function($scope, $http){
    $http({
        method:'get',
        url:'http://www.json-generator.com/api/json/get/bTRWzhCvuG?indent=2',
        header:{'Content-Type':'application/json'},
    }).success(function(data,status,headers, config){   
        $scope.productDescription = data;       
    }).error(function(data, status,headers, config){

    })
})

When retrieve the content in View page then p tag not support in angular js. What should i do? please let me know. Thanks in advance.

5
  • I would assume that cat.product.fullDescription doesn't output the fullDescription data as raw html, but instead treats it as browser output, eg encodes the html. Commented Feb 8, 2016 at 11:40
  • try using $sce like this in your success $scope.productDescription = $sce.trustAsHtml(data) Commented Feb 8, 2016 at 11:41
  • @Sachin. This is not works. Explain me more? Commented Feb 8, 2016 at 11:59
  • Did you try implementing the ngBindHtml ? as it is suggested in the answer? Commented Feb 8, 2016 at 12:07
  • @Saching. Yes but i did'nt install sanitize. ngBindHtml can work without sanitize? Commented Feb 8, 2016 at 12:09

1 Answer 1

0

use ngBindHtml

<div ng-controller="chooseProductDescription">
      <div ng-repeat="cat in productDescription">
                <div ng-bind-html="cat.product.fullDescription"></div>             
       </div>
</div>
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.