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. dockerfile - [docker build image失败- npm install]2. docker - 各位电脑上有多少个容器啊?容器一多,自己都搞混了,咋办呢?3. docker不显示端口映射呢?4. javascript - 如图,百度首页,查看源代码为什么什么都没有?5. 关于layuiadmin中表格按钮提交问题求解!!!!6. python相关问题求解决,有偿7. javascript - 怎么用flatlist替换scrollview?8. javascript - 项目用IE浏览器打开修改前端内容,后台数据修改了,但是前端页面内容不变,用谷歌浏览器测试前端页面可以刷新,求大神解决。9. javascript - vue2.0中使用vue2-dropzone的demo,vue2-dropzone的github网址是什么??百度不到。10. 布局 - android 微信切换栏

网公网安备