Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/424.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何计算对象';具有给定属性值的数组中的(Angular FirebaseRealtime)_Javascript_Angular_Firebase Realtime Database - Fatal编程技术网

Javascript 如何计算对象';具有给定属性值的数组中的(Angular FirebaseRealtime)

Javascript 如何计算对象';具有给定属性值的数组中的(Angular FirebaseRealtime),javascript,angular,firebase-realtime-database,Javascript,Angular,Firebase Realtime Database,当这是真的时,我想数一数“身高”。我该怎么办 组件技术 getAttDetails(ıd){ this.afAuth.user.subscribe(user => this.serviceCourses.getAttDetails(ıd,user).subscribe(detail => console.log(detail))); } 服务课程 getAttDetails(ıd,user:firebase.User){ return this

当这是真的时,我想数一数“身高”。我该怎么办

组件技术

getAttDetails(ıd){
        this.afAuth.user.subscribe(user => this.serviceCourses.getAttDetails(ıd,user).subscribe(detail => console.log(detail)));
      }
服务课程

getAttDetails(ıd,user:firebase.User){
    return  this.db.list('/denemeDersler/'+ıd+'/attendance/'+user.uid).snapshotChanges().pipe(map(changes => changes
      .map(c => ({key: c.payload.key, ...c.payload.val()}))));
   }

你可以这样做

假设您的数据集是这样的

let arr=[{key:'2020-01-15',statu:true},{key:'2020-01-11',statu:true},{key:'2020-01-10',statu:false}]
让计数=0;
arr.map(item=>{if(item.statu===true){count++})

console.log(count)//output:2
是否要计算对象中的键数?否?希望我的对象具有“statu”并且当statu为真时,希望计算statu请不要使用链接向帖子中添加详细信息。该链接最终将过期,这将降低您的帖子对将来有类似问题的用户的价值输入'Object'first console.log中不存在statu'。是否在
listTrue
中出现了什么?@zafer,其中
变量
您将获得
对象的
数组
,就像在您的第一个屏幕截图中一样?将我的数组对象更改为任何问题都没有了,但当我第一次单击时,我看到0,但我需要看到4。@zafer如果此解决方案帮助您接受答案,那么其他人也可以从中获得帮助。