Я внедрил поставщика routeReuseStrategy в моем Angular приложении с этим ресурсом здесь https://medium.com/@rajeshpillai1996 / what-is-routereusestrategy-how-to-cache-components-with- angular -routereusestrategy-82da7790cd2b . Но теперь у меня есть один маршрут с дочерними маршрутами, и когда я использую data:{reuse:true}
на родительском маршруте или на дочерних маршрутах, он не работает. Компоненты перезагружаются снова между маршрутизацией.
В моем случае все супер с Home и Welcome Component. Как я могу реализовать это в компоненте WithChildRoutes и его дочерних маршрутах?
const routes: Routes = [
{path:'home' , component:HomeComponent, data:{reuse:true}},
{path:'welcome' , component:WelcomeComponent,data:{reuse:true}},
{
path:'compo-with-child-routes' , component:WithChildRoutesComponent,
data:{reuse:true},
children:[
{path:'child-one' , component:Child1Component},
{path:'child-two' , component:Child2Component},
{path:'' , redirectTo:'child-one' , pathMatch:'full'}
]
}
];