Dismiss
Announcing Stack Overflow Documentation

We started with Q&A. Technical documentation is next, and we need your help.

Whether you're a beginner or an experienced developer, you can contribute.

Sign up and start helping → Learn more about Documentation →
$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'?

share|improve this question

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>

share|improve this answer
    
No sorry! didn't work ! i tried the same with single quotes around 'count(1) but no luck – Spdexter Jul 29 at 9:43
1  
Please see the updated answer. – Shashank Agrawal Jul 29 at 9:44
1  
Thanks a lot the latest worked! – Spdexter Jul 29 at 9:47

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.