1

Thank you in advance for helping me with this problem.

I am unable to enable back the button, I have 3 components where the actual button which need to be disabled is present in A component.

Flow:

On A component load, there is a popup shown which is from component C and on clicking Approve button from component c, in component B emitter function hits and I am emitting Boolean as false in that function and subscribing to it in component A and assigning the value to the property which is making the button disabled, but button still remains in disabled mode only.The local property in component A is also getting assigned false but the button still says in disabled mode only.

I used BehaviorSubject of type boolean and made the initial value as null.

Component: A

.html

<button[disabled]="(processing$ | async)" kendoButton>

.ts

processing$ = new BehaviorSubject < boolean > (false);

ngOnInit() {
  this.userMessageService.currentQRMApprovedStatus.
  subscribe(
    isQRMApproved => {
      if (isQRMApproved)
        this.processing$.next(false);
    });
}
Sivakumar Tadisetti
  • 4,865
  • 7
  • 34
  • 56
Adithya
  • 183
  • 1
  • 2
  • 16
  • There is no problem with components B,C where C component is giving the event emitter back to B component via function.B component : onConfirmPopupClose(isOk: boolean): void { if (isOk) { this.userMessageService.updateQRMApprovedState(false); } – Adithya Oct 12 '20 at 05:20
  • 1
    Have you tried changeDetectionRef ? https://angular.io/api/core/ChangeDetectorRef – Puria Rad Jahanbani Oct 12 '20 at 05:23
  • @Puriajahanbani : Thank you for your help, I tried it but still button stays in disabled model only, for testing I used expression binding too : {{(processing$ | async)}} and its returning me false which is right,. i added setInterval(() => { // require view to be updated this.changeDetectorRef.markForCheck(); }, 1000); in constructor and added changeDetection: ChangeDetectionStrategy.OnPush too but no luck. – Adithya Oct 12 '20 at 05:41
  • I recommend you to add a test button to parent component and log the form with it. Check if the form is valid or not. If the form is valid but the button is not responding, probably the Dom has not changed and you should run cdr.changeDetection(). But if the form is not valid, probably your core logic needs to be fixed in typescript. – Puria Rad Jahanbani Oct 12 '20 at 05:59

0 Answers0