varun sharma February 2016

Text not wrapping in p tag from Json text file.(Angular Js)

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.

Answers


n00dl3 February 2016

use ngBindHtml

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

Post Status

Asked in February 2016
Viewed 1,117 times
Voted 14
Answered 1 times

Search




Leave an answer