单击按钮时,有时会两次调用subscribe()

时间:2019-09-16 09:29:05

标签: angular typescript ionic-framework ionic2 ionic3

我的html页面上有一个按钮,单击此按钮后,数据将保存在数据库中。有时,同一条记录在数据库中保存了两次,无法调试原因。

我的代码:

home.html

<button ion-button class="orng_btn" (click)="has_pass()" [disabled]="disabled_kot == true?true:false">Save</button>

home.ts

    has_pass()
    {
       this.disabled_kot = true;

    // calling webservice
    this.user.k_kot(encodeURIComponent(JSON.stringify(this.f_arr))).subscribe(data=>{
    console.log(data,"data");
    this.navCtrl.setRoot('HomePage');
    });
    }

请注意-按下按钮时,我们使用setRoot刷新页面,是不是有时可能会创建此页面的2个实例?还是我们需要做些其他事情?

0 个答案:

没有答案