gpt4 book ai didi

javascript - Angular 未在我的 json 中渲染

转载 作者:行者123 更新时间:2023-11-28 15:37:14 25 4
gpt4 key购买 nike

我正在尝试使用 Angular 来在页面上显示 json 中的元素。它不起作用。我想做的事情非常简单。但它不起作用

这是我的代码:

http://jsfiddle.net/sqxmyrcj/1/

(function(){
var app = angular.module('store', []);

app.controller('PortfolioController',function(){
this.product = gem;
});

var gem =
{
name: 'TEmp',
aboutme: 'A Computer Science student at <br>The University Canada.<br> <br>A Software Engineer'
};

})();

最佳答案

所有其他评论/答案都有一些有效的观点。您面临的主要问题是 1) 您使用过时的 Angular 版本;-) 和 2) 您需要使用 $sce 服务才能创建可信 HTML:

(function(app){
app.controller('PortfolioController',function($sce){
this.product = {
name: 'TEmp',
aboutme: $sce.trustAsHtml('A Computer Science student at <br>The University Canada.<br> <br>A Software Engineer')
};
});

})(angular.module('store', []));

http://jsfiddle.net/sqxmyrcj/7/

干杯只园

关于javascript - Angular 未在我的 json 中渲染 <br>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25232983/

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