K
K
Konstantin2020-04-16 20:53:16
Angular
Konstantin, 2020-04-16 20:53:16

How to save a statement for MatTab?

I use tabs with routing.

<nav mat-tab-nav-bar>
  <a mat-tab-link
     *ngFor="let link of links"
     [routerLink]="link.path"
     routerLinkActive #rla="routerLinkActive"
     [active]="link.isActive">
    {{link.label}}
  </a>
</nav>

<router-outlet></router-outlet>


After the user has worked in tab 1 (filled out the form) and switched to any other and then returned, the tab statement - namely the component loaded by routing - disappears.

How is this solved in Angular, except for saving the statement in the service or in the storage? Does MatTab itself have a solution in it?

My problem is that the Label tabs themselves need to be in the same component. And body tabs in another. But as you can see from the docks, the material does not allow separating tabs from the content of tabs.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Shvets, 2020-04-17
@Junart1

except for saving the statement in the service or in the storage

This is the most optimal way.
Of course, you can arrange a projection of the view from somewhere outside into your tab, but this is an unnecessary complication.
Write components in such a way that their task is only one thing - to display content. Do not store.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question