vendredi 30 octobre 2020

uncheck material checkbox after closing modal

In an application I've a checkbox that filters a table. In that table you have a button to return a product. After closing the confirmation modal I want to uncheck the checkbox.

The ngModelChange is working well if I check/uncheck box manually.

I've tried (ngModelChange), (change), [checked]

angular version:8

HTML:

<mat-checkbox (ngModelChange)="changeSeeOnlyInUse()" [(ngModel)]="seeOnlyInUse">Show Only Products in use.</mat-checkbox>
<div class="table-container"> 
    <table>
        ...
    </table>
</div>

TS:

ngOnInit() {this.seeOnlyInUse=false;}

public returnProduct(registration) {
    //do some stuff and open modal
    modalRef.afterClosed().subscribe (response => {
        // do some stuff
        this.seeOnlyInUse = false; //<- now I want to uncheck box})
}

public changeSeeOnlyInUse(){
    this.seeOnlyProductsInUse = !this.seeOnlyProductsInUse;
    // do some stuff }  
    




Aucun commentaire:

Enregistrer un commentaire