Now I have written a direactive to replace the click operation. After clicking, the button is disabled. For example, click is a method to call login, and the button is restored after the promise of the login service ends.
Now you can simulate click and disable the button, but you cannot get the result of promise. Is there any good method?
//directive (大概的代码)
@Output() czClick = new EventEmitter();
@HostListener("click",["$event"])
onClick(e){
this.renderer.setElementAttribute(this.element.nativeElement,'disabled','true');
this.czClick.emit(e);
}
//html
<button cz-click (czClick)="login()">登录</button>
Mainly this.czClick.emit(e); If the promise result of login cannot be obtained here, the effect of the button cannot be modified in the end state.
Ask for advice 0-0
(czClick)="login($event)"
吧?