在control属性设置为false后,ActivityIndicator不会关闭

loading...


0

我正在使用Anuglar6和Nativescript尝试在我做api工作时登录ActivityIndicator(登录) . 这工作正常,但在我将布尔处理设置为false后,它仍显示旋转动画 .

<StackLayout class="container">
  <StackLayout class="form">
    <Label class="h3 lbl" text="Användarnamn:" textWrap="true"></Label>
    <TextField class="field input input-border" [isEnabled]="!processing" keyboardType="email" autocapitalizationType="none" (textChange)="setUsername($event)" (returnPress)="focusPassword()"></TextField>
    <Label class="h3 lbl" text="Lösenord:" textWrap="true"></Label>
    <TextField #password class="field input input-border" [isEnabled]="!processing" secure="true" autocapitalizationType="none" (textChange)="setPassword($event)"></TextField>
    <Button class="loginBtn" text="LOGGA IN" [isEnabled]="!processing" (tap)="submit()"></Button>
    <ActivityIndicator row="1" [busy]="processing" width="100" height="100" class="activity-indicator"></ActivityIndicator>
  </StackLayout>
</StackLayout>
private processing = false;

    public login(): void {
    this.processing = true;
    this.authService.login(this.username, this.password)
        .subscribe(
            () => {
                console.log(this.processing);
                this.processing = false;
                console.log(this.processing);
                // this.router.navigate(['home']);
            });
}

console.log打印输出

JS: true
JS: false

我在这做错了什么?

loading...

1回答

  • 0

    非常感谢你在这件事上的所有帮助 . 我不想在更多时间点击按钮关闭ActivityIndicator . 我想在登录任务完成后转向 . 数据已更新,但ui没有 . 我用BehaviorSubject解决了它 .

    public processing$ = new BehaviorSubject<boolean>(false);
    
    public login(): void {
        this.processing$.next(true);
        this.authService.login(this.username, this.password)
            .subscribe(
                () => {
                    console.log(this.processing$);
                    this.processing$.next(false);
                    console.log(this.processing$);
                    this.router.navigate(['home']);
                });
    }
    

    现在它相应地更新了ui .

评论

暂时没有评论!