Store Features
This store feature provides access to the route params. The mapParams receives the route params object, use it to transform it to an object, this will create a computed for each prop return by the mapParams function
// example route /products/:id/
const ProductDetailStore = signalStore(
withRouteParams(({ id }) => ({ id })),
withCalls(() => ({
loadProductDetail: (id: string) =>
inject(ProductService).getProductDetail(id),
})),
withHooks(({ loadProductDetail, id }) => ({
onInit: () => {
loadProductDetail(id());
},
})),
);
Property | Description | Value |
---|---|---|
mapParams | A function to transform the params before they are stored. | (params: Params, data?: any) => T, |
No state signals are generated.
Generates a computed signals, per prop returned by the mapParams function.
// for withRouteParams(({ id , foor}) => ({ id, foo: +foo }))
{
id: string;
foo: number;
}
No methods are generated by this function.