Angular手动更新formGroup并将表单设置为dirty = false?

时间:2019-05-29 04:35:54

标签: angular-formbuilder

此代码可以正常工作,但是一旦我按“更新”,此消息仍显示如何避免这种情况?

canDeactivate(
    component: StaffEditComponent,
    currentRoute: ActivatedRouteSnapshot, 
    currentState: RouterStateSnapshot
): Observable<boolean>|Promise<boolean>|boolean {
    if (component.staffEditForm.dirty){
        return confirm(`You have unsaved changes. Do You wish to navigate anyways?`);
    }
    return true;
}

0 个答案:

没有答案