#18 Router APIを再発見! (2020-06-10) #26
lacolaco
announced in
Show Notes
Replies: 1 comment
-
Router API再発見
https://stackblitz.com/angular/egnnljjvrgj?file=src%2Fapp%2Fapp.component.html RouterModulehttps://angular.jp/api/router/RouterModule class RouterModule {
static forRoot(routes: Routes, config?: ExtraOptions): ModuleWithProviders<RouterModule>
static forChild(routes: Routes): ModuleWithProviders<RouterModule>
}
interface ExtraOptions {
enableTracing?: boolean
useHash?: boolean
initialNavigation?: InitialNavigation
errorHandler?: ErrorHandler
preloadingStrategy?: any
onSameUrlNavigation?: 'reload' | 'ignore'
scrollPositionRestoration?: 'disabled' | 'enabled' | 'top'
anchorScrolling?: 'disabled' | 'enabled'
scrollOffset?: [number, number] | (() => [number, number])
paramsInheritanceStrategy?: 'emptyOnly' | 'always'
malformedUriErrorHandler?: (error: URIError, urlSerializer: UrlSerializer, url: string) => UrlTree
urlUpdateStrategy?: 'deferred' | 'eager'
relativeLinkResolution?: 'legacy' | 'corrected'
} Routehttps://angular.jp/api/router/Route
interface Route {
path?: string
pathMatch?: string
matcher?: UrlMatcher
component?: Type<any>
redirectTo?: string
outlet?: string
canActivate?: any[]
canActivateChild?: any[]
canDeactivate?: any[]
canLoad?: any[]
data?: Data
resolve?: ResolveData
children?: Routes
loadChildren?: LoadChildren
runGuardsAndResolvers?: RunGuardsAndResolvers
} interface CanActivate {
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree
}
interface CanActivateChild {
canActivateChild(childRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree
}
interface CanDeactivate<T> {
canDeactivate(component: T, currentRoute: ActivatedRouteSnapshot, currentState: RouterStateSnapshot, nextState?: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree
} RouterOutlet
Routerhttps://angular.jp/api/router/Router
UrlTreeinterface UrlTree {
root: UrlSegmentGroup
queryParams: Params
fragment: string | null
queryParamMap: ParamMap
toString(): string
}
const tree: UrlTree =
router.parseUrl('/team/33/(user/victor//support:help)?debug=true#fragment');
const f = tree.fragment; // return 'fragment'
const q = tree.queryParams; // returns {debug: 'true'}
const g: UrlSegmentGroup = tree.root.children[PRIMARY_OUTLET];
const s: UrlSegment[] = g.segments; // returns 2 segments 'team' and '33'
g.children[PRIMARY_OUTLET].segments; // returns 2 segments 'user' and 'victor'
g.children['support'].segments; // return 1 segment 'help' NavigationExtras
RouterLink
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
ng-japan OnAir vol.18 "Router API 再発見" - YouTube
ng-japan OnAirって何?:thinking_face:
Angular日本ユーザー会が主催するYouTube Liveです!
過去のOnAirの配信アーカイブはこちらから視聴できます!
内容
会場
https://www.youtube.com/channel/UCayXpiOPFQh9MWePLoEFLmg/live
🔔 YouTubeチャンネルを購読 しておくと、配信開始のお知らせを受け取ることができます!
💃 出演者紹介
lacolaco
Google Developers Expert / Angular日本ユーザー会 代表
https://twitter.com/laco2net
okunokentaro
Angular日本ユーザー会、ng-kyoto オーガナイザ
https://twitter.com/okunokentaro
しみきょん
エンジニア at DMM.com / Angular日本ユーザー会のスタッフしてます
https://twitter.com/shimikyonkyon
Beta Was this translation helpful? Give feedback.
All reactions