2
$completed = [Object { count(1)="7", gid="306"}, Object { count(1)="1", gid="311"}]

How do I get count(1) = 7 in an HTML template?

<div class="{{ completed | filter : group.gid }}">

so

{{ completed | filter : group.gid }}  

evaluates to

[{ "count(1)":"7","gid":"306"}]

I just need '7'?

1 Answer 1

1

Here you go:

<div class="{{(completed | filter: group.gid)[0]["count(1)"]}}" >

See the working demo:

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>

Sign up to request clarification or add additional context in comments.

1 Comment

No sorry! didn't work ! i tried the same with single quotes around 'count(1) but no luck

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.