【发布时间】:2020-12-23 01:22:11
【问题描述】:
如果 id 为空,我希望变量 x 为真。我会使用 if 和 else 但不能在管道中这样做。请帮帮我。
private x = false;
private y = false;
ngOnInit() {
this.subscribe = this.route.params.pipe(
map(({ id }) => id),
filter(id => !!id), // <---- here
switchMap((id: string) =>
this.shippingService.getShippingById(id)))
.subscribe(
res => {
this.shippingData = res;
this.y= true;
},
err => this.error = err.error,
);
}
【问题讨论】:
标签: angular typescript filter pipe