Routing Instructions
...
import { FrrriRoutingModule } from '@frrri/ngxs-crud/routing';
@NgModule({
...
imports: [
...
FrrriRoutingModule.forRoot()
],
})
export class AppModule { }Configuring your routes
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { frrriRoutes, instructions, getActive, getMany, reset } from '@frrri/ngxs-crud/routing';
const routes: Routes = [
{
path: '',
data: instructions({
'entities': reset(), // Reset all entities when entering the route
'entities.posts': getMany() // Then get posts
})
},
{
path: ':id',
data: instructions({
'entities.posts': getActive() // Get active post (defaults to set param :id active)
})
}
];
@NgModule({
imports: [
RouterModule.forChild(
frrriRoutes(routes) // Important so route instructions can be resolved
)
],
exports: [RouterModule]
})
export class PostsRoutingModule { }Last updated