There is a CMS dependency in the pagelayoutservice implementation: cmsservice
The metadata information of the current page is maintained through cms.getcurrentpage.
Get the current page context from routingservice, and then extract the actual data from the ngrx store in central:
Implementation of routingservice.getpagecontext: read from store.
For the arrow function of typescript, the following two methods are correct:
The first one: the typescript compiler automatically deduces if the return type is not specified for the function.
let fun5 = (data:number)=> data * data;
Second: complete writing. The number after the first arrow indicates that the return type is number
let fun5:(data:number) =>number = (data:number)=> data * data;
Select accepts an input parameter: routingselector.getnextpagecontext, which is a function: the input type is any and the output type is pagecontext:
The type definition of getnextpagecontext is exactly the same as that of mapfn specified in the select interface:
(state: any) => PageContext
select<any, PageContext>(mapFn: (state: any) => PageContext): (source$: Observable<any>) => Observable<PageContext>
Type definition of select itself: return a function. The input parameter received by the function is observable of type T, and the output is observable object of type K.
Let’s assume that the routingstate has been obtained, and write the mapper function first. Then go back and solve the problem of how to get the routingstate, that is, getrouterstate.
More Jerry’s original articles are: “Wang Zixi”: