angular2中数组的布尔值计数

时间:2017-05-29 07:27:14

标签: angular2-routing angular2-template angular2-forms

this.employee = [             {                 名称:" A",                 经验丰富:真实;                 },             {               名称:" B",                 经验丰富:真实;                 },                  {               名称:" C",                 经验丰富:虚假;                 },

//这里我需要真值的计数

1 个答案:

答案 0 :(得分:0)

尝试:

const experienced = this.employee.reduce((acc, e) => e.isexperienced ? acc+1 : acc, 0);

其次,您的员工数组不正确:

  • ;true
  • 之后应该没有false
  • 没有结束]