R
R
Roman Rakzin2015-05-31 12:09:06
Angular
Roman Rakzin, 2015-05-31 12:09:06

How to count the number of defined values ​​in an angular model?

Good afternoon.
There is data like
[{name:'John', phone:'555',myvalue:1},{name:'Mary', phone:'800',myvalue:0}, etc.
How to count the number of defined values ​​in an angular model where myvalue=0 ?
Thanks

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Sergey, 2015-05-31
Protko @Fesor

var count = data.filter(item => item.myvalue === 0).length;

A
Alexander Tartmin, 2015-05-31
@baskerville42

https://docs.angularjs.org/api/ng/function/angular... ;)

R
Roman Rakzin, 2015-06-01
@TwoRS

$scope.count_true = 0;
$scope.count_false = 0;
$scope.count_study = 0;
$.each($scope.SpisokVoprosov, function(index, value){
if(value.reshenie==="1"){$scope.count_true++;}
if(value.reshenie==="0"){$scope .count_false++;}
if(value.reshenie===""){$scope.count_study++;}
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question