Issue
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,
}
Solution
this.employeeL = res as Array<Awinjard>
this.employeeL = this.employeeL.filter((employee) => employee.status);
Answered By - Michael Desigaud
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.