Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
325 views
in Technique[技术] by (71.8m points)

Angular8 rxjs 过滤数据基础问题

想取出有parentProjectId的数据,line1 输出如下数据,line2 undefined .

该如何写?

   this.projectChildAll.subscribe((v: ProjectsChild) => console.log(v))   // line1
   this.projectChildAll.pipe(filter((v: ProjectsChild) => v.parentProjectId)).subscribe(v => console.log(v))  //line2

image


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

v是一个数组,不是ProjectsChild类型,自然不能取得parentProjectId。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...