angular.js - angular ng-class里面的引号问题
巴扎黑
巴扎黑 2017-05-15 16:57:14
[AngularJS讨论组]

我有一个指令,template里面的ng-class="{glyphicon-chevron-down:isOpened, glyphicon-chevron-right: !isOpened}", 给glyphicon-chevron-down和glyphicon-chevron-right加单引号和双引号都会报错,不加引号也会报错(ng-class里面的classname如果有 - 的话要加引号的)。这种情况该怎么办呢?

.directive('brandItem', function (){
    return {
        restrict: 'EA',
        require: '^brandList',
        transclude: true,
        replace: true,
        scope: {
            title: '='
        },
        template: '
  • ' +'' +'

    ' +'
  • ', link: function (scope, element, attrs, brandListCtrl){ scope.isOpened = false; brandListCtrl.addItem(scope); scope.toggle = function (){ this.isOpened = !this.isOpened; brandListCtrl.getOpened(scope); } } } });
    巴扎黑
    巴扎黑

    全部回复(2)
    某草草

    ng-class="{'active':selected}"
    1.4.5 下有效。以此类推。。单引号应该有效

    滿天的星座

    第一,你的angular版本是多少?这个很关键!


    详细信息,参见 http://stackoverflow.com/questions/15557151/ngclass-style-with-dash-in-key

    热门教程
    更多>
    最新下载
    更多>
    网站特效
    网站源码
    网站素材
    前端模板
    关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
    php中文网:公益在线php培训,帮助PHP学习者快速成长!
    关注服务号 技术交流群
    PHP中文网订阅号
    每天精选资源文章推送
    PHP中文网APP
    随时随地碎片化学习

    Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号