youssef115
youssef115

Reputation: 37

Property 'status' does not exist on type 'string'. in angular

I try to make an Ionic app (with angular)

here my problem: Property 'status' does not exist on type 'string'

after I get the data from the database I want to make control for the data shown but I get this error can I solve this problem in angular without making other function that controls data from the backend ??

As you can see in this code I will get all the employees but I want to get only the employees that status=true

I'm missing something please help

here the code :

ts file :

  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) {

        }
      }
    })
  }

here the interface.ts

export interface Awinjard {

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


}

Upvotes: 0

Views: 989

Answers (1)

Michael Desigaud
Michael Desigaud

Reputation: 2135

this.employeeL = res as Array<Awinjard>
this.employeeL = this.employeeL.filter((employee) => employee.status);

Upvotes: 2

Related Questions