0

我尝试制作一个 Ionic 应用程序(带角度)

这是我的问题:Property 'status' does not exist on type 'string'

从数据库中获取数据后,我想对显示的数据进行控制,但出现此错误,我可以在不创建其他控制后端数据的功能的情况下以角度解决此问题吗?

正如您在这段代码中看到的,我将获得所有员工,但我只想获得 status=true 的员工

我错过了一些东西请帮忙

这里的代码:

ts文件:

  states: boolean;
  employeeL:Array<Awinjard> = [];

  constructor(private activatedRoute: ActivatedRoute,private AounInfoService:AounInfoService,private root:Router,private awinjard:AwinnjaridService,private plt:Platform,private loadingctrl:LoadingController) { }

  ngOnInit() {
    this.folder = this.activatedRoute.snapshot.paramMap.get('id');
    this.awinjard.getAllAwinjard().subscribe(res => {
      this.employeeL = res as Array<Awinjard>
      for (const key in this.employeeL) {
        if (key.status) {

        }
      }
    })
  }

这里是interface.ts

export interface Awinjard {

     _id: string,
    matricule: number,
    fullname:string ,
    status: boolean,
    done: number,
    mustBeDone: number,


}

4

1 回答 1

2
this.employeeL = res as Array<Awinjard>
this.employeeL = this.employeeL.filter((employee) => employee.status);
于 2021-03-25T13:51:12.473 回答