1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

Angular Material Tab : Prevent tab change of mat-tab-group if the form in current tab is dirty

Discussão em 'Angular' iniciado por jophab, Julho 29, 2025.

  1. jophab

    jophab Guest

    I was trying to prevent tab change of mat-tab, if the form in currently active tab is dirty.

    But I couldn't find a way to intercept the tab change event.

    <mat-tab-group>

    <mat-tab label="Tab 0" >

    // Tab 0 Content

    </mat-tab>

    <mat-tab label="Tab 1" >

    // Tab 1 Content

    </mat-tab>

    <mat-tab label="Tab 2" >

    // Tab 2 Content

    </mat-tab>

    </mat-tab-group>


    Even though there is a selectedTabChange event, we can't prevent tab change. we can only switch tab programatically after tab change.

    Continue reading...

Compartilhe esta Página