angular.js - angular ng-class里面的引号问题
问题描述
我有一个指令,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: ’<li ng-click='toggle()' class='list-group-item'>’ +’<label><span ng-class='{glyphicon-chevron-down:isOpened, glyphicon-chevron-right: !isOpened}'></span> {{name}}</label>’ +’<p ng-transclude></p>’+’</li>’,link: function (scope, element, attrs, brandListCtrl){ scope.isOpened = false; brandListCtrl.addItem(scope); scope.toggle = function (){this.isOpened = !this.isOpened;brandListCtrl.getOpened(scope); }} }});
问题解答
回答1:ng-class='{’active’:selected}'1.4.5 下有效。以此类推。。单引号应该有效
回答2:第一,你的angular版本是多少?这个很关键!
详细信息,参见 http://stackoverflow.com/questions/15557151/ngclass-style-with-dash-in-key
相关文章:
1. 求救一下,用新版的phpstudy,数据库过段时间会消失是什么情况?2. node.js - Angular-webpack-Starter, 怎么把NodeJS添加进项目里?3. android-studio - android studio自带模拟器中的本地“图库”所对应的路径是什么?4. node.js - yo webapp构建项目时报错了,如图5. javascript - gulp-nodemon 使用重启express 服务器的时候端口被占用6. python 多进程如何调试7. 【python小白】 问关于之初始化一次对象的问题8. java - 微信开发遇到一个 bug。。access_token 有关的9. thinkphp中Controller里面使用Request::File(’image’);10. 人工智能 - python 机器学习 医疗数据 怎么学

网公网安备