# Notes Note is an input value that hub consumes. It's just route information by itself ## Getting Know with Input For example, you want to describe the **About** module**.** So, it's obvious that you need to specify the path. Use example: ```typescript // grabbing interface import { RouteNote } from 'routeshub'; // declaring the note export const aboutNote: RouteNote = { path: 'about', lazy: 'app/views/about/about.module#AboutModule' }; ``` Be sure to read **API** section to know more. {% page-ref page="../api/" %} Great, we've declared one of About module routes. Let's declare the rest. ```typescript // grabbing interfaces import { RootRoute, RouteNote } from 'routeshub'; /* * describing routes which About module has * extends RootRoute talks that module has default ('root') path */ export interface AboutNotes extends RootRoute { team: RouteNote; location: RouteNote; } // declaring module's notes export const aboutNotes: RoutesNotes = { root: { path: '' }, team: { path: 'team' }, location: { path: 'location' } }; ``` _Notes_ are just a collection of key-value.
Notes
Note is input to reproduce the slice
Creating Note
Takes two arguments (the second is optional) and one generic type. The first argument is the usual routes variable that needs angular router. The second argument is the options for name customization. As you can see above, we've changed default root
and wildcard
to home
and notFound
Usage example:
import { createNote, Note } from 'routeshub'; import { ViewComponent } from '../view.component'; export const routes: Routes = [ { path: '', component: ViewComponent, }, { path: '**', redirectTo: '' } ]; export interface AppNote { home: Note; notFound: Note; } export const appNote = createNote<AppNote>(routes, { root: 'home', wildcard: 'notFound' }); // it will produce an object equals to { home: { path: '', name: 'home' }, notFound:{ path: '**', name: 'notFound' } }
Let's take a look on another example
import { createNote, Note } from 'routeshub'; import { ViewComponent } from '../view.component'; import { SuperPlaceComponent } from '../super-place.component'; import { CityComponent } from '../city.component'; export const routes: Routes = [ { path: '', pathMatch: 'full', component: ViewComponent, children: [ { path: '', redirectTo: 'about', }, { path: 'about', loadChildren: () => import('app/views/about/about.module').then(m => m.AboutModule) } ] }, { path: 'super-place', pathMatch: 'full', component: SuperPlaceComponent }, { path: 'super_place/:city', pathMatch: 'full', component: CityComponent } { path: '**', redirectTo: '' } ]; export interface AppChildrenNote extends Root { about: Note; } export interface AppNote extends Root<AppChildrenNote> { superPlace: Note; city: Note; wildcard: Note; } export const appNote = createNote<AppNote>(routes); // it will produce an object equals to { root: { path: '', name: 'root', children: [ { root: { path: '', name: 'root' }, about: { path: 'about', name: 'about' } } ]}, superPlace: { path: 'super-place', name: 'superPlace' }, city: { path: 'super_place/:city', name: 'city' }, notFound:{ path: '**', name: 'notFound' } }
You may have lots of questions here.
First, routeshub converts paths into camelCase keys.
Variables in paths are also recognizable.
Notes interfaces could have shortcuts for reusable reason. Root interface just adds root: Note
to common interface. Also, root path can have children routes. If so, then just pass generic children Root<ChildrenNote>
as illustrated above.
If you want to know more then be sure to read API section
{% page-ref page="../api/" %}