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

标签 javascript jquery html angularjs

我试图在我的模型中包含 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/

相关文章:

javascript - javascript和lua计算结果不同

jquery - 如何在翻转时使用 jquery 更改单个图像的大小?

javascript - Flex - 调用 JavaScript 函数并打开显示数据的弹出窗口

javascript - grunt build 在使用 auth0 时生成错误

javascript - TypeError : require(. ..).jsdom 不是函数

javascript - 无法将 Prop 中的功能传递给组件 | react

javascript - 搜索句号并随机决定在 50% 的时间后添加一个词

jquery - 使用 jQuery 的悬停问题

javascript - 在 .load() 页面之后执行 javascript

javascript - 作为 element.contains() 参数输入的有效属性是什么?