Search code examples
javascripthtmlangularjsjsonmobile-angular-ui

HTML text not rendered in proper way from JSON in MOBILE ANGULAR UI


I am using MOBILE ANGULAR UI frame work. When i retrieved the Text(include tags) from JSON then text show with tags in .html file. I have seen one link but i did not get solution. This link is AngularJS : Insert HTML into view. I already install ngsanitize but when i include in app.js, then my project dont show anythink.

SCREEN SHOT:
enter image description here

App.js

angular.module('Y', [
  'ngRoute',
  'mobile-angular-ui',
  'Y.controllers.Main',
])

COTROLLER:

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

    })
})

ngsanitize is compulsory for the view of text? But i also tried ngsanitize, i have seen one more link that one is.How to install ngSanitize?

i want to simple solution for the view of text.

HTML.

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

I read this link many time (AngularJS : Insert HTML into view) but i did not get solution till now. I am using mobile angular ui framework, may be its have different approach.

I want to show only text without tags in html page in MOBILE ANGULAR UI. Please share your ideas.


Solution

  • I guess.. you are not including ngSanitize properly

    see this plunk for better understanding.. try including.. angular-sanitize after angular and before your script

    And in your Markup

    instead of this {{cat.product.fullDescription}} use..

    <span ng-bind-html="cat.product.fullDescription"></span>