已解决,应该在resolve
守卫处用res.homeDatas[0]
取值.
如下代码,line1
输出数据如下图,line2
输出undefined
,line3
当然无法比较. 该如何取值?
export type Project = {
id: string;
name: string;
parentProjectId?: string;
}
ngOnInit() {
this.activateInfo.data
.pipe(map(res => {
return this.filterProject(res.homeDatas,this.projectId)
}))
}
filterProject(projects: Project[], projectId: string) {
return projects.filter((someworkbook: Project) => {
console.log(someworkbook); //line1
console.log(someworkbook.parentProjectId); //line2
if ( someworkbook.parentProjectId === projectId) { //line3
console.log('===> true');
return true;
}
console.log('===> false');
return false;
});
}
已解决!
应该在
resolve
守卫处用res.homeDatas[0]
取值.