我正在研究 angularJS,我的代码很好,但我被困在一个地方,我找不到为什么ng-class-even
指令中需要额外的引号。
在这一行<tr ng-repeat="x in records" ng-class-even='"striped"'>
中为什么 striped 是这样写"'striped'"
而不是这样写的"striped"
.striped {
color:white;
background-color:black;
}
<body ng-app="myApp">
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<table ng-controller="myCtrl">
<tr ng-repeat="x in records" ng-class-even="'striped'">
<td>{{x.Name}}</td>
<td>{{x.Country}}</td>
</tr>
</table>
<script>
var app = angular.module("myApp", []);
app.controller("myCtrl", function($scope) {
$scope.records = [
{
"Name" : "Alfreds Futterkiste",
"Country" : "Germany"
},
{
"Name" : "Berglunds snabbköp",
"Country" : "Sweden"
},
{
"Name" : "Centro comercial Moctezuma",
"Country" : "Mexico"
},
{
"Name" : "Ernst Handel",
"Country" : "Austria"
}
]
});
</script>
</body>