角传递组件上下文以订阅complete()吗?

时间:2019-01-29 08:33:14

标签: javascript angular

我有一个页面,该页面显示表中的所有插入记录,如果(情况1)没有插入记录,请显示一个类似按钮的按钮,否则(情况2)它将向您显示表,其中存储了所有记录D b。该页面是相同的,但是会从http响应中检查情况1还是2。

我在检查oncomplete订阅时遇到问题,在这种情况下,我问是否可以在()=> {}函数(如

)中传递模块上下文

this.is_loading = true
this.show_content = 0

constructor(private webapi: WebApiService){
this.webapi
    .getData()
    .pipe(concatMap((result: dataResult.KeyValueResult<string, string>[]) => from(result)))
    .subscribe(
        (element: dataResult.KeyValueResult<string, string>) => {
            this.is_loading = false;
            this.show_content = 2
        },
        (error: any) => {
            console.error('error on widgetList', error);
        },
        () => {
            // here, i can't see this
            if(this.show_content != 2) { // if 2 then i have rows
                this.show_content = 1
                this.is_loading = false
            }
        }
    );
}

0 个答案:

没有答案