'How to enable a dynamically added button in a disabled fieldset with angular

I have a disabled fieldset with multiple input fields added dynamically. I'm trying to enable a single button inside the disabled fieldset without enabling the whole form or going into edit mode. I did find some questions similar to this question. However, none of those have dynamically added buttons into the fieldset(uses ngx-formly). The answers given in this link does help with statically added buttons in the fieldset. I would really appreciate your help on doing similar thing on dynamic buttons. Button gets added into the ng-container below. Need to access that button and enable it.

    <form [formGroup]="form"
      (ngSubmit)="submit()">
    <fieldset [disabled]="!to.isEditing">
        <ng-container #fieldComponent></ng-container>

        <div class="form-submit-buttons-row row clearfix"
             *ngIf="to.showButton && to.isEditing">
            <button type="submit"
                    class="pull-right m-l-md btn btn-rounded btn-primary">
                <span class="p-w-md">Save</span>
            </button>

            <button type="button"
                    class="pull-right m-l-md btn btn-rounded btn-white"
                    (click)="cancel()">
                <span class="p-w-md">Cancel</span>
            </button>
        </div>
    </fieldset>
</form>

EDIT I figured out a workaround to my problem. Instead of enabling the button inside the whole fieldset, i displayed the content of the button click inline in disabled mode.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source