gpt4 book ai didi

javascript - Json 文本文件中的文本未换行为 p 标记。(Angular Js)

转载 作者:行者123 更新时间:2023-11-28 06:24:10 25 4
gpt4 key购买 nike

我正在从 JSON 检索数据,并检索一些文本内容,但文本内容不支持 p 标签。我将向您展示屏幕截图以获取提示。
enter image description here

当我们检索文本内容时,它显示如下(带有 p 标签)。JSON 网址:

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){

})
})

当检索 View 页面中的内容时,Angular js 不支持 p 标签。我应该怎么办?请告诉我。提前致谢。

最佳答案

使用ngBindHtml

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

关于javascript - Json 文本文件中的文本未换行为 p 标记。(Angular Js),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35268683/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com