角JS NG重复使用条件纳克级不适用CSS类
问题描述:
我有一个NG类NG重复并不在我的CSS类的名称中连字符的情况下应用CSS类:
I have a ng repeat with a ng class that doesn't apply the css class in the case where my css class has a hyphen in the name:
<li
ng-repeat="item in items"
ng-class="{'i-someclass' : item.Id > 10}">
{{item .name}}
</li>
难道我做错了什么?如果我更改CSS类名isomeclass它的工作原理。
AngularJS v1.0.7
Am I doing anything wrong? If I change the css class name to isomeclass it works. AngularJS v1.0.7
答
对于我来说,你的code的工作原理是。
For me, your code works as is.
这里是一个plunker ,演示code。
JS:
var app = angular.module('myApp', []);
app.controller('Ctrl', function($scope) {
$scope.items = [
{ Id: 1, name: "item1" },
{ Id: 10, name: "item1" },
{ Id: 11, name: "item1" }
];
});
HTML:
<html ng-app="myApp">
<head>
<script data-require="angular.js@*" data-semver="1.2.4" src="http://code.angularjs.org/1.2.4/angular.js"></script>
<link rel="stylesheet" href="style.css" />
<script src="script.js"></script>
</head>
<body ng-controller="Ctrl">
<h1>Hello Plunker!</h1>
<ul>
<li
ng-repeat="item in items"
ng-class="{'i-someclass' : item.Id > 10}">
{{item .name}}
</li>
</ul>
</body>
</html>
CSS:
.i-someclass {
color: red;
}