$completed = [Object { count(1)="7", gid="306"}, Object { count(1)="1", gid="311"}]
如何在HTML模板中获取count(1) = 7
?
<div class="{{ completed | filter : group.gid }}">
所以
{{ completed | filter : group.gid }}
评估为
[{ "count(1)":"7","gid":"306"}]
我只需要'7'?
答案 0 :(得分:1)
你走了:
<div class="{{(completed | filter: group.gid)[0]["count(1)"]}}" >
参见工作演示:
var app = angular.module("sa", []);
app.controller("FooController", function($scope) {
$scope.group = {
gid: 7
};
$scope.completed = [{
"count(1)": "7",
gid: "306"
}, {
"count(1)": "1",
gid: "311"
}]
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="sa" ng-controller="FooController">
{{(completed | filter: group.gid)[0]["count(1)"]}}
</div>