gpt4 book ai didi

javascript - Angular JS : HTML in $scope throws jshint error?

转载 作者:行者123 更新时间:2023-12-03 12:39:58 25 4
gpt4 key购买 nike

我试图在我的模型中包含 html 标签,这是一个包含 b 的简单案例标签:

 .controller('AccordionDemoCtrl', ['$scope',
function($scope) {


$scope.oneAtATime = true;

$scope.groups = [{
title: "Dynamic Group Header - 1",
content: "Dynamic Group Body - 1"
}, {
title: "Dynamic Group Header - 2",
content: "<b>Dynamic Group Body - 2</b> Lorem ipsum dolor sit amet, consectetur adipisicing elit. Suscipit nobis nihil eaque, et quam similique tempore nam modi iusto nesciunt."
}];

$scope.items = ['Item 1', 'Item 2', 'Item 3'];

$scope.addItem = function() {
var newItemNo = $scope.items.length + 1;
$scope.items.push('Item ' + newItemNo);
};

}
]);

并且,在 html 中我有 <div ng-bind-html="group.content"></div>

我按照我的意愿在 HTML 中显示为粗体,但是当 Grunt 运行时,jshint 失败“由于警告而中止”。如果我删除 b标签,它有效。

我在这里遗漏了什么吗?

最佳答案

一开始我以为你用过<div ng-bind-html="group.content"></div>在 ng-repeat 中,如果没有,您的程序将无法运行,其次请向我们提供该警告,这将有助于了解发生了什么。

谢谢:)

关于javascript - Angular JS : HTML in $scope throws jshint error?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23568352/

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