HTML 移动设备 JSON 中的文本未以正确方式呈现 ANGULAR UI
HTML text not rendered in proper way from JSON in MOBILE ANGULAR UI
我正在使用移动 ANGULAR UI 框架。当我从 JSON 中检索到文本(包括标签)时,文本会在 .html 文件中显示。我见过一个 link 但我没有得到解决方案。这个link是AngularJS : Insert HTML into view。
我已经安装了 ngsanitize,但是当我包含在 app.js 中时,我的项目不会显示任何想法。
屏幕截图:
App.js
angular.module('Y', [
'ngRoute',
'mobile-angular-ui',
'Y.controllers.Main',
])
控制器:
.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 是强制查看文本的吗?但我也试过 ngsanitize,我又看到了一个 link 那一个是。How to install ngSanitize?
我想要一个简单的文本视图解决方案。
HTML.
<div ng-repeat="cat in productDescription">
{{cat.product.fullDescription}}
</div>
我读了这个 link 很多遍 (AngularJS : Insert HTML into view) 但直到现在我还没有得到解决方案。我正在使用移动 angular ui 框架,可能它有不同的方法。
我想在移动 ANGULAR UI 的 html 页面中只显示没有标签的文本。
请分享您的想法。
我想..你没有正确地包括 ngSanitize
为了更好地理解,请参阅此 plunk.. 尝试在 angular
之后和 script
之前包括.. angular-sanitize
并且在您的标记中
而不是 {{cat.product.fullDescription}}
使用..
<span ng-bind-html="cat.product.fullDescription"></span>
我正在使用移动 ANGULAR UI 框架。当我从 JSON 中检索到文本(包括标签)时,文本会在 .html 文件中显示。我见过一个 link 但我没有得到解决方案。这个link是AngularJS : Insert HTML into view。 我已经安装了 ngsanitize,但是当我包含在 app.js 中时,我的项目不会显示任何想法。
屏幕截图:
App.js
angular.module('Y', [
'ngRoute',
'mobile-angular-ui',
'Y.controllers.Main',
])
控制器:
.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 是强制查看文本的吗?但我也试过 ngsanitize,我又看到了一个 link 那一个是。How to install ngSanitize?
我想要一个简单的文本视图解决方案。
HTML.
<div ng-repeat="cat in productDescription">
{{cat.product.fullDescription}}
</div>
我读了这个 link 很多遍 (AngularJS : Insert HTML into view) 但直到现在我还没有得到解决方案。我正在使用移动 angular ui 框架,可能它有不同的方法。
我想在移动 ANGULAR UI 的 html 页面中只显示没有标签的文本。 请分享您的想法。
我想..你没有正确地包括 ngSanitize
为了更好地理解,请参阅此 plunk.. 尝试在 angular
之后和 script
angular-sanitize
并且在您的标记中
而不是 {{cat.product.fullDescription}}
使用..
<span ng-bind-html="cat.product.fullDescription"></span>