router.d.ts 90 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013
  1. /**
  2. * @license Angular v8.1.0
  3. * (c) 2010-2019 Google LLC. https://angular.io/
  4. * License: MIT
  5. */
  6. import { AfterContentInit } from '@angular/core';
  7. import { ApplicationRef } from '@angular/core';
  8. import { ChangeDetectorRef } from '@angular/core';
  9. import { Compiler } from '@angular/core';
  10. import { ComponentFactoryResolver } from '@angular/core';
  11. import { ComponentRef } from '@angular/core';
  12. import { ElementRef } from '@angular/core';
  13. import { EventEmitter } from '@angular/core';
  14. import { HashLocationStrategy } from '@angular/common';
  15. import { InjectionToken } from '@angular/core';
  16. import { Injector } from '@angular/core';
  17. import { Location } from '@angular/common';
  18. import { LocationStrategy } from '@angular/common';
  19. import { ModuleWithProviders } from '@angular/core';
  20. import { NgModuleFactory } from '@angular/core';
  21. import { NgModuleFactoryLoader } from '@angular/core';
  22. import { NgProbeToken } from '@angular/core';
  23. import { Observable } from 'rxjs';
  24. import { OnChanges } from '@angular/core';
  25. import { OnDestroy } from '@angular/core';
  26. import { OnInit } from '@angular/core';
  27. import { PathLocationStrategy } from '@angular/common';
  28. import { PlatformLocation } from '@angular/common';
  29. import { Provider } from '@angular/core';
  30. import { QueryList } from '@angular/core';
  31. import { Renderer2 } from '@angular/core';
  32. import { SimpleChanges } from '@angular/core';
  33. import { Type } from '@angular/core';
  34. import { Version } from '@angular/core';
  35. import { ViewContainerRef } from '@angular/core';
  36. import { ViewportScroller } from '@angular/common';
  37. /**
  38. * @description
  39. *
  40. * Contains the information about a route associated with a component loaded in an
  41. * outlet. An `ActivatedRoute` can also be used to traverse the router state tree.
  42. *
  43. * {@example router/activated-route/module.ts region="activated-route"
  44. * header="activated-route.component.ts" linenums="false"}
  45. *
  46. * @publicApi
  47. */
  48. export declare class ActivatedRoute {
  49. /** An observable of the URL segments matched by this route */
  50. url: Observable<UrlSegment[]>;
  51. /** An observable of the matrix parameters scoped to this route */
  52. params: Observable<Params>;
  53. /** An observable of the query parameters shared by all the routes */
  54. queryParams: Observable<Params>;
  55. /** An observable of the URL fragment shared by all the routes */
  56. fragment: Observable<string>;
  57. /** An observable of the static and resolved data of this route. */
  58. data: Observable<Data>;
  59. /** The outlet name of the route. It's a constant */
  60. outlet: string;
  61. /** The component of the route. It's a constant */
  62. component: Type<any> | string | null;
  63. /** The current snapshot of this route */
  64. snapshot: ActivatedRouteSnapshot;
  65. /** The configuration used to match this route */
  66. readonly routeConfig: Route | null;
  67. /** The root of the router state */
  68. readonly root: ActivatedRoute;
  69. /** The parent of this route in the router state tree */
  70. readonly parent: ActivatedRoute | null;
  71. /** The first child of this route in the router state tree */
  72. readonly firstChild: ActivatedRoute | null;
  73. /** The children of this route in the router state tree */
  74. readonly children: ActivatedRoute[];
  75. /** The path from the root of the router state tree to this route */
  76. readonly pathFromRoot: ActivatedRoute[];
  77. readonly paramMap: Observable<ParamMap>;
  78. readonly queryParamMap: Observable<ParamMap>;
  79. toString(): string;
  80. }
  81. /**
  82. * @description
  83. *
  84. * Contains the information about a route associated with a component loaded in an
  85. * outlet at a particular moment in time. ActivatedRouteSnapshot can also be used to
  86. * traverse the router state tree.
  87. *
  88. * ```
  89. * @Component({templateUrl:'./my-component.html'})
  90. * class MyComponent {
  91. * constructor(route: ActivatedRoute) {
  92. * const id: string = route.snapshot.params.id;
  93. * const url: string = route.snapshot.url.join('');
  94. * const user = route.snapshot.data.user;
  95. * }
  96. * }
  97. * ```
  98. *
  99. * @publicApi
  100. */
  101. export declare class ActivatedRouteSnapshot {
  102. /** The URL segments matched by this route */
  103. url: UrlSegment[];
  104. /** The matrix parameters scoped to this route */
  105. params: Params;
  106. /** The query parameters shared by all the routes */
  107. queryParams: Params;
  108. /** The URL fragment shared by all the routes */
  109. fragment: string;
  110. /** The static and resolved data of this route */
  111. data: Data;
  112. /** The outlet name of the route */
  113. outlet: string;
  114. /** The component of the route */
  115. component: Type<any> | string | null;
  116. /** The configuration used to match this route **/
  117. readonly routeConfig: Route | null;
  118. /** The root of the router state */
  119. readonly root: ActivatedRouteSnapshot;
  120. /** The parent of this route in the router state tree */
  121. readonly parent: ActivatedRouteSnapshot | null;
  122. /** The first child of this route in the router state tree */
  123. readonly firstChild: ActivatedRouteSnapshot | null;
  124. /** The children of this route in the router state tree */
  125. readonly children: ActivatedRouteSnapshot[];
  126. /** The path from the root of the router state tree to this route */
  127. readonly pathFromRoot: ActivatedRouteSnapshot[];
  128. readonly paramMap: ParamMap;
  129. readonly queryParamMap: ParamMap;
  130. toString(): string;
  131. }
  132. /**
  133. * @description
  134. *
  135. * Represents the start of end of the Resolve phase of routing. See note on
  136. * `ActivationStart` for use of this experimental API.
  137. *
  138. * @publicApi
  139. */
  140. export declare class ActivationEnd {
  141. /** @docsNotRequired */
  142. snapshot: ActivatedRouteSnapshot;
  143. constructor(
  144. /** @docsNotRequired */
  145. snapshot: ActivatedRouteSnapshot);
  146. toString(): string;
  147. }
  148. /**
  149. * @description
  150. *
  151. * Represents the start of end of the Resolve phase of routing. See note on
  152. * `ActivationEnd` for use of this experimental API.
  153. *
  154. * @publicApi
  155. */
  156. export declare class ActivationStart {
  157. /** @docsNotRequired */
  158. snapshot: ActivatedRouteSnapshot;
  159. constructor(
  160. /** @docsNotRequired */
  161. snapshot: ActivatedRouteSnapshot);
  162. toString(): string;
  163. }
  164. /**
  165. * @description
  166. *
  167. * Interface that a class can implement to be a guard deciding if a route can be activated.
  168. * If all guards return `true`, navigation will continue. If any guard returns `false`,
  169. * navigation will be cancelled. If any guard returns a `UrlTree`, current navigation will
  170. * be cancelled and a new navigation will be kicked off to the `UrlTree` returned from the
  171. * guard.
  172. *
  173. * ```
  174. * class UserToken {}
  175. * class Permissions {
  176. * canActivate(user: UserToken, id: string): boolean {
  177. * return true;
  178. * }
  179. * }
  180. *
  181. * @Injectable()
  182. * class CanActivateTeam implements CanActivate {
  183. * constructor(private permissions: Permissions, private currentUser: UserToken) {}
  184. *
  185. * canActivate(
  186. * route: ActivatedRouteSnapshot,
  187. * state: RouterStateSnapshot
  188. * ): Observable<boolean|UrlTree>|Promise<boolean|UrlTree>|boolean|UrlTree {
  189. * return this.permissions.canActivate(this.currentUser, route.params.id);
  190. * }
  191. * }
  192. *
  193. * @NgModule({
  194. * imports: [
  195. * RouterModule.forRoot([
  196. * {
  197. * path: 'team/:id',
  198. * component: TeamComponent,
  199. * canActivate: [CanActivateTeam]
  200. * }
  201. * ])
  202. * ],
  203. * providers: [CanActivateTeam, UserToken, Permissions]
  204. * })
  205. * class AppModule {}
  206. * ```
  207. *
  208. * You can alternatively provide a function with the `canActivate` signature:
  209. *
  210. * ```
  211. * @NgModule({
  212. * imports: [
  213. * RouterModule.forRoot([
  214. * {
  215. * path: 'team/:id',
  216. * component: TeamComponent,
  217. * canActivate: ['canActivateTeam']
  218. * }
  219. * ])
  220. * ],
  221. * providers: [
  222. * {
  223. * provide: 'canActivateTeam',
  224. * useValue: (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) => true
  225. * }
  226. * ]
  227. * })
  228. * class AppModule {}
  229. * ```
  230. *
  231. * @publicApi
  232. */
  233. export declare interface CanActivate {
  234. canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree;
  235. }
  236. /**
  237. * @description
  238. *
  239. * Interface that a class can implement to be a guard deciding if a child route can be activated.
  240. * If all guards return `true`, navigation will continue. If any guard returns `false`,
  241. * navigation will be cancelled. If any guard returns a `UrlTree`, current navigation will
  242. * be cancelled and a new navigation will be kicked off to the `UrlTree` returned from the
  243. * guard.
  244. *
  245. * ```
  246. * class UserToken {}
  247. * class Permissions {
  248. * canActivate(user: UserToken, id: string): boolean {
  249. * return true;
  250. * }
  251. * }
  252. *
  253. * @Injectable()
  254. * class CanActivateTeam implements CanActivateChild {
  255. * constructor(private permissions: Permissions, private currentUser: UserToken) {}
  256. *
  257. * canActivateChild(
  258. * route: ActivatedRouteSnapshot,
  259. * state: RouterStateSnapshot
  260. * ): Observable<boolean|UrlTree>|Promise<boolean|UrlTree>|boolean|UrlTree {
  261. * return this.permissions.canActivate(this.currentUser, route.params.id);
  262. * }
  263. * }
  264. *
  265. * @NgModule({
  266. * imports: [
  267. * RouterModule.forRoot([
  268. * {
  269. * path: 'root',
  270. * canActivateChild: [CanActivateTeam],
  271. * children: [
  272. * {
  273. * path: 'team/:id',
  274. * component: TeamComponent
  275. * }
  276. * ]
  277. * }
  278. * ])
  279. * ],
  280. * providers: [CanActivateTeam, UserToken, Permissions]
  281. * })
  282. * class AppModule {}
  283. * ```
  284. *
  285. * You can alternatively provide a function with the `canActivateChild` signature:
  286. *
  287. * ```
  288. * @NgModule({
  289. * imports: [
  290. * RouterModule.forRoot([
  291. * {
  292. * path: 'root',
  293. * canActivateChild: ['canActivateTeam'],
  294. * children: [
  295. * {
  296. * path: 'team/:id',
  297. * component: TeamComponent
  298. * }
  299. * ]
  300. * }
  301. * ])
  302. * ],
  303. * providers: [
  304. * {
  305. * provide: 'canActivateTeam',
  306. * useValue: (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) => true
  307. * }
  308. * ]
  309. * })
  310. * class AppModule {}
  311. * ```
  312. *
  313. * @publicApi
  314. */
  315. export declare interface CanActivateChild {
  316. canActivateChild(childRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree;
  317. }
  318. /**
  319. * @description
  320. *
  321. * Interface that a class can implement to be a guard deciding if a route can be deactivated.
  322. * If all guards return `true`, navigation will continue. If any guard returns `false`,
  323. * navigation will be cancelled. If any guard returns a `UrlTree`, current navigation will
  324. * be cancelled and a new navigation will be kicked off to the `UrlTree` returned from the
  325. * guard.
  326. *
  327. * ```
  328. * class UserToken {}
  329. * class Permissions {
  330. * canDeactivate(user: UserToken, id: string): boolean {
  331. * return true;
  332. * }
  333. * }
  334. *
  335. * @Injectable()
  336. * class CanDeactivateTeam implements CanDeactivate<TeamComponent> {
  337. * constructor(private permissions: Permissions, private currentUser: UserToken) {}
  338. *
  339. * canDeactivate(
  340. * component: TeamComponent,
  341. * currentRoute: ActivatedRouteSnapshot,
  342. * currentState: RouterStateSnapshot,
  343. * nextState: RouterStateSnapshot
  344. * ): Observable<boolean|UrlTree>|Promise<boolean|UrlTree>|boolean|UrlTree {
  345. * return this.permissions.canDeactivate(this.currentUser, route.params.id);
  346. * }
  347. * }
  348. *
  349. * @NgModule({
  350. * imports: [
  351. * RouterModule.forRoot([
  352. * {
  353. * path: 'team/:id',
  354. * component: TeamComponent,
  355. * canDeactivate: [CanDeactivateTeam]
  356. * }
  357. * ])
  358. * ],
  359. * providers: [CanDeactivateTeam, UserToken, Permissions]
  360. * })
  361. * class AppModule {}
  362. * ```
  363. *
  364. * You can alternatively provide a function with the `canDeactivate` signature:
  365. *
  366. * ```
  367. * @NgModule({
  368. * imports: [
  369. * RouterModule.forRoot([
  370. * {
  371. * path: 'team/:id',
  372. * component: TeamComponent,
  373. * canDeactivate: ['canDeactivateTeam']
  374. * }
  375. * ])
  376. * ],
  377. * providers: [
  378. * {
  379. * provide: 'canDeactivateTeam',
  380. * useValue: (component: TeamComponent, currentRoute: ActivatedRouteSnapshot, currentState:
  381. * RouterStateSnapshot, nextState: RouterStateSnapshot) => true
  382. * }
  383. * ]
  384. * })
  385. * class AppModule {}
  386. * ```
  387. *
  388. * @publicApi
  389. */
  390. export declare interface CanDeactivate<T> {
  391. canDeactivate(component: T, currentRoute: ActivatedRouteSnapshot, currentState: RouterStateSnapshot, nextState?: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree;
  392. }
  393. /**
  394. * @description
  395. *
  396. * Interface that a class can implement to be a guard deciding if children can be loaded.
  397. *
  398. * ```
  399. * class UserToken {}
  400. * class Permissions {
  401. * canLoadChildren(user: UserToken, id: string, segments: UrlSegment[]): boolean {
  402. * return true;
  403. * }
  404. * }
  405. *
  406. * @Injectable()
  407. * class CanLoadTeamSection implements CanLoad {
  408. * constructor(private permissions: Permissions, private currentUser: UserToken) {}
  409. *
  410. * canLoad(route: Route, segments: UrlSegment[]): Observable<boolean>|Promise<boolean>|boolean {
  411. * return this.permissions.canLoadChildren(this.currentUser, route, segments);
  412. * }
  413. * }
  414. *
  415. * @NgModule({
  416. * imports: [
  417. * RouterModule.forRoot([
  418. * {
  419. * path: 'team/:id',
  420. * component: TeamComponent,
  421. * loadChildren: 'team.js',
  422. * canLoad: [CanLoadTeamSection]
  423. * }
  424. * ])
  425. * ],
  426. * providers: [CanLoadTeamSection, UserToken, Permissions]
  427. * })
  428. * class AppModule {}
  429. * ```
  430. *
  431. * You can alternatively provide a function with the `canLoad` signature:
  432. *
  433. * ```
  434. * @NgModule({
  435. * imports: [
  436. * RouterModule.forRoot([
  437. * {
  438. * path: 'team/:id',
  439. * component: TeamComponent,
  440. * loadChildren: 'team.js',
  441. * canLoad: ['canLoadTeamSection']
  442. * }
  443. * ])
  444. * ],
  445. * providers: [
  446. * {
  447. * provide: 'canLoadTeamSection',
  448. * useValue: (route: Route, segments: UrlSegment[]) => true
  449. * }
  450. * ]
  451. * })
  452. * class AppModule {}
  453. * ```
  454. *
  455. * @publicApi
  456. */
  457. export declare interface CanLoad {
  458. canLoad(route: Route, segments: UrlSegment[]): Observable<boolean> | Promise<boolean> | boolean;
  459. }
  460. /**
  461. * @description
  462. *
  463. * Represents the start of end of the Resolve phase of routing. See note on
  464. * `ChildActivationStart` for use of this experimental API.
  465. *
  466. * @publicApi
  467. */
  468. export declare class ChildActivationEnd {
  469. /** @docsNotRequired */
  470. snapshot: ActivatedRouteSnapshot;
  471. constructor(
  472. /** @docsNotRequired */
  473. snapshot: ActivatedRouteSnapshot);
  474. toString(): string;
  475. }
  476. /**
  477. * @description
  478. *
  479. * Represents the start of end of the Resolve phase of routing. See note on
  480. * `ChildActivationEnd` for use of this experimental API.
  481. *
  482. * @publicApi
  483. */
  484. export declare class ChildActivationStart {
  485. /** @docsNotRequired */
  486. snapshot: ActivatedRouteSnapshot;
  487. constructor(
  488. /** @docsNotRequired */
  489. snapshot: ActivatedRouteSnapshot);
  490. toString(): string;
  491. }
  492. /**
  493. * Store contextual information about the children (= nested) `RouterOutlet`
  494. *
  495. * @publicApi
  496. */
  497. export declare class ChildrenOutletContexts {
  498. private contexts;
  499. /** Called when a `RouterOutlet` directive is instantiated */
  500. onChildOutletCreated(childName: string, outlet: RouterOutlet): void;
  501. /**
  502. * Called when a `RouterOutlet` directive is destroyed.
  503. * We need to keep the context as the outlet could be destroyed inside a NgIf and might be
  504. * re-created later.
  505. */
  506. onChildOutletDestroyed(childName: string): void;
  507. /**
  508. * Called when the corresponding route is deactivated during navigation.
  509. * Because the component get destroyed, all children outlet are destroyed.
  510. */
  511. onOutletDeactivated(): Map<string, OutletContext>;
  512. onOutletReAttached(contexts: Map<string, OutletContext>): void;
  513. getOrCreateContext(childName: string): OutletContext;
  514. getContext(childName: string): OutletContext | null;
  515. }
  516. /**
  517. * Convert a `Params` instance to a `ParamMap`.
  518. *
  519. * @publicApi
  520. */
  521. export declare function convertToParamMap(params: Params): ParamMap;
  522. /**
  523. *
  524. * Represents static data associated with a particular route.
  525. *
  526. * @see `Route#data`
  527. *
  528. * @publicApi
  529. */
  530. export declare type Data = {
  531. [name: string]: any;
  532. };
  533. /**
  534. * @description
  535. *
  536. * A default implementation of the `UrlSerializer`.
  537. *
  538. * Example URLs:
  539. *
  540. * ```
  541. * /inbox/33(popup:compose)
  542. * /inbox/33;open=true/messages/44
  543. * ```
  544. *
  545. * DefaultUrlSerializer uses parentheses to serialize secondary segments (e.g., popup:compose), the
  546. * colon syntax to specify the outlet, and the ';parameter=value' syntax (e.g., open=true) to
  547. * specify route specific parameters.
  548. *
  549. * @publicApi
  550. */
  551. export declare class DefaultUrlSerializer implements UrlSerializer {
  552. /** Parses a url into a `UrlTree` */
  553. parse(url: string): UrlTree;
  554. /** Converts a `UrlTree` into a url */
  555. serialize(tree: UrlTree): string;
  556. }
  557. /**
  558. * A string of the form `path/to/file#exportName` that acts as a URL for a set of routes to load.
  559. *
  560. * @see `Route#loadChildren`
  561. * @publicApi
  562. * @deprecated the `string` form of `loadChildren` is deprecated in favor of the proposed ES dynamic
  563. * `import()` expression, which offers a more natural and standards-based mechanism to dynamically
  564. * load an ES module at runtime.
  565. */
  566. export declare type DeprecatedLoadChildren = string;
  567. /**
  568. * @description
  569. *
  570. * Represents the detached route tree.
  571. *
  572. * This is an opaque value the router will give to a custom route reuse strategy
  573. * to store and retrieve later on.
  574. *
  575. * @publicApi
  576. */
  577. export declare type DetachedRouteHandle = {};
  578. /**
  579. * @description
  580. *
  581. * Error handler that is invoked when a navigation errors.
  582. *
  583. * If the handler returns a value, the navigation promise will be resolved with this value.
  584. * If the handler throws an exception, the navigation promise will be rejected with
  585. * the exception.
  586. *
  587. * @publicApi
  588. */
  589. declare type ErrorHandler = (error: any) => any;
  590. /**
  591. * @description
  592. *
  593. * Represents a router event, allowing you to track the lifecycle of the router.
  594. *
  595. * The sequence of router events is:
  596. *
  597. * - `NavigationStart`,
  598. * - `RouteConfigLoadStart`,
  599. * - `RouteConfigLoadEnd`,
  600. * - `RoutesRecognized`,
  601. * - `GuardsCheckStart`,
  602. * - `ChildActivationStart`,
  603. * - `ActivationStart`,
  604. * - `GuardsCheckEnd`,
  605. * - `ResolveStart`,
  606. * - `ResolveEnd`,
  607. * - `ActivationEnd`
  608. * - `ChildActivationEnd`
  609. * - `NavigationEnd`,
  610. * - `NavigationCancel`,
  611. * - `NavigationError`
  612. * - `Scroll`
  613. *
  614. * @publicApi
  615. */
  616. export declare type Event = RouterEvent | RouteConfigLoadStart | RouteConfigLoadEnd | ChildActivationStart | ChildActivationEnd | ActivationStart | ActivationEnd | Scroll;
  617. /**
  618. * @description
  619. *
  620. * Represents options to configure the router.
  621. *
  622. * @publicApi
  623. */
  624. export declare interface ExtraOptions {
  625. /**
  626. * Makes the router log all its internal events to the console.
  627. */
  628. enableTracing?: boolean;
  629. /**
  630. * Enables the location strategy that uses the URL fragment instead of the history API.
  631. */
  632. useHash?: boolean;
  633. /**
  634. * Disables the initial navigation.
  635. */
  636. initialNavigation?: InitialNavigation;
  637. /**
  638. * A custom error handler.
  639. */
  640. errorHandler?: ErrorHandler;
  641. /**
  642. * Configures a preloading strategy. See `PreloadAllModules`.
  643. */
  644. preloadingStrategy?: any;
  645. /**
  646. * Define what the router should do if it receives a navigation request to the current URL.
  647. * By default, the router will ignore this navigation. However, this prevents features such
  648. * as a "refresh" button. Use this option to configure the behavior when navigating to the
  649. * current URL. Default is 'ignore'.
  650. */
  651. onSameUrlNavigation?: 'reload' | 'ignore';
  652. /**
  653. * Configures if the scroll position needs to be restored when navigating back.
  654. *
  655. * * 'disabled'--does nothing (default). Scroll position will be maintained on navigation.
  656. * * 'top'--set the scroll position to x = 0, y = 0 on all navigation.
  657. * * 'enabled'--restores the previous scroll position on backward navigation, else sets the
  658. * position to the anchor if one is provided, or sets the scroll position to [0, 0] (forward
  659. * navigation). This option will be the default in the future.
  660. *
  661. * You can implement custom scroll restoration behavior by adapting the enabled behavior as
  662. * follows:
  663. * ```typescript
  664. * class AppModule {
  665. * constructor(router: Router, viewportScroller: ViewportScroller) {
  666. * router.events.pipe(
  667. * filter((e: Event): e is Scroll => e instanceof Scroll)
  668. * ).subscribe(e => {
  669. * if (e.position) {
  670. * // backward navigation
  671. * viewportScroller.scrollToPosition(e.position);
  672. * } else if (e.anchor) {
  673. * // anchor navigation
  674. * viewportScroller.scrollToAnchor(e.anchor);
  675. * } else {
  676. * // forward navigation
  677. * viewportScroller.scrollToPosition([0, 0]);
  678. * }
  679. * });
  680. * }
  681. * }
  682. * ```
  683. */
  684. scrollPositionRestoration?: 'disabled' | 'enabled' | 'top';
  685. /**
  686. * Configures if the router should scroll to the element when the url has a fragment.
  687. *
  688. * * 'disabled'--does nothing (default).
  689. * * 'enabled'--scrolls to the element. This option will be the default in the future.
  690. *
  691. * Anchor scrolling does not happen on 'popstate'. Instead, we restore the position
  692. * that we stored or scroll to the top.
  693. */
  694. anchorScrolling?: 'disabled' | 'enabled';
  695. /**
  696. * Configures the scroll offset the router will use when scrolling to an element.
  697. *
  698. * When given a tuple with two numbers, the router will always use the numbers.
  699. * When given a function, the router will invoke the function every time it restores scroll
  700. * position.
  701. */
  702. scrollOffset?: [number, number] | (() => [number, number]);
  703. /**
  704. * Defines how the router merges params, data and resolved data from parent to child
  705. * routes. Available options are:
  706. *
  707. * - `'emptyOnly'`, the default, only inherits parent params for path-less or component-less
  708. * routes.
  709. * - `'always'`, enables unconditional inheritance of parent params.
  710. */
  711. paramsInheritanceStrategy?: 'emptyOnly' | 'always';
  712. /**
  713. * A custom malformed uri error handler function. This handler is invoked when encodedURI contains
  714. * invalid character sequences. The default implementation is to redirect to the root url dropping
  715. * any path or param info. This function passes three parameters:
  716. *
  717. * - `'URIError'` - Error thrown when parsing a bad URL
  718. * - `'UrlSerializer'` - UrlSerializer that’s configured with the router.
  719. * - `'url'` - The malformed URL that caused the URIError
  720. * */
  721. malformedUriErrorHandler?: (error: URIError, urlSerializer: UrlSerializer, url: string) => UrlTree;
  722. /**
  723. * Defines when the router updates the browser URL. The default behavior is to update after
  724. * successful navigation. However, some applications may prefer a mode where the URL gets
  725. * updated at the beginning of navigation. The most common use case would be updating the
  726. * URL early so if navigation fails, you can show an error message with the URL that failed.
  727. * Available options are:
  728. *
  729. * - `'deferred'`, the default, updates the browser URL after navigation has finished.
  730. * - `'eager'`, updates browser URL at the beginning of navigation.
  731. */
  732. urlUpdateStrategy?: 'deferred' | 'eager';
  733. /**
  734. * Enables a bug fix that corrects relative link resolution in components with empty paths.
  735. * Example:
  736. *
  737. * ```
  738. * const routes = [
  739. * {
  740. * path: '',
  741. * component: ContainerComponent,
  742. * children: [
  743. * { path: 'a', component: AComponent },
  744. * { path: 'b', component: BComponent },
  745. * ]
  746. * }
  747. * ];
  748. * ```
  749. *
  750. * From the `ContainerComponent`, this will not work:
  751. *
  752. * `<a [routerLink]="['./a']">Link to A</a>`
  753. *
  754. * However, this will work:
  755. *
  756. * `<a [routerLink]="['../a']">Link to A</a>`
  757. *
  758. * In other words, you're required to use `../` rather than `./`. This is currently the default
  759. * behavior. Setting this option to `corrected` enables the fix.
  760. */
  761. relativeLinkResolution?: 'legacy' | 'corrected';
  762. }
  763. /**
  764. * @description
  765. *
  766. * Represents the end of the Guard phase of routing.
  767. *
  768. * @publicApi
  769. */
  770. export declare class GuardsCheckEnd extends RouterEvent {
  771. /** @docsNotRequired */
  772. urlAfterRedirects: string;
  773. /** @docsNotRequired */
  774. state: RouterStateSnapshot;
  775. /** @docsNotRequired */
  776. shouldActivate: boolean;
  777. constructor(
  778. /** @docsNotRequired */
  779. id: number,
  780. /** @docsNotRequired */
  781. url: string,
  782. /** @docsNotRequired */
  783. urlAfterRedirects: string,
  784. /** @docsNotRequired */
  785. state: RouterStateSnapshot,
  786. /** @docsNotRequired */
  787. shouldActivate: boolean);
  788. toString(): string;
  789. }
  790. /**
  791. * @description
  792. *
  793. * Represents the start of the Guard phase of routing.
  794. *
  795. * @publicApi
  796. */
  797. export declare class GuardsCheckStart extends RouterEvent {
  798. /** @docsNotRequired */
  799. urlAfterRedirects: string;
  800. /** @docsNotRequired */
  801. state: RouterStateSnapshot;
  802. constructor(
  803. /** @docsNotRequired */
  804. id: number,
  805. /** @docsNotRequired */
  806. url: string,
  807. /** @docsNotRequired */
  808. urlAfterRedirects: string,
  809. /** @docsNotRequired */
  810. state: RouterStateSnapshot);
  811. toString(): string;
  812. }
  813. /**
  814. * @description
  815. *
  816. * Represents an option to configure when the initial navigation is performed.
  817. *
  818. * * 'enabled' - the initial navigation starts before the root component is created.
  819. * The bootstrap is blocked until the initial navigation is complete.
  820. * * 'disabled' - the initial navigation is not performed. The location listener is set up before
  821. * the root component gets created.
  822. * * 'legacy_enabled'- the initial navigation starts after the root component has been created.
  823. * The bootstrap is not blocked until the initial navigation is complete. @deprecated
  824. * * 'legacy_disabled'- the initial navigation is not performed. The location listener is set up
  825. * after @deprecated
  826. * the root component gets created.
  827. * * `true` - same as 'legacy_enabled'. @deprecated since v4
  828. * * `false` - same as 'legacy_disabled'. @deprecated since v4
  829. *
  830. * The 'enabled' option should be used for applications unless there is a reason to have
  831. * more control over when the router starts its initial navigation due to some complex
  832. * initialization logic. In this case, 'disabled' should be used.
  833. *
  834. * The 'legacy_enabled' and 'legacy_disabled' should not be used for new applications.
  835. *
  836. * @publicApi
  837. */
  838. declare type InitialNavigation = true | false | 'enabled' | 'disabled' | 'legacy_enabled' | 'legacy_disabled';
  839. /**
  840. *
  841. * A string of the form `path/to/file#exportName` that acts as a URL for a set of routes to load,
  842. * or a function that returns such a set.
  843. *
  844. * The string form of `LoadChildren` is deprecated (see `DeprecatedLoadChildren`). The function
  845. * form (`LoadChildrenCallback`) should be used instead.
  846. *
  847. * @see `Route#loadChildren`.
  848. * @publicApi
  849. */
  850. export declare type LoadChildren = LoadChildrenCallback | DeprecatedLoadChildren;
  851. /**
  852. *
  853. * A function that is called to resolve a collection of lazy-loaded routes.
  854. *
  855. * Often this function will be implemented using an ES dynamic `import()` expression. For example:
  856. *
  857. * ```
  858. * [{
  859. * path: 'lazy',
  860. * loadChildren: () => import('./lazy-route/lazy.module').then(mod => mod.LazyModule),
  861. * }];
  862. * ```
  863. *
  864. * This function _must_ match the form above: an arrow function of the form
  865. * `() => import('...').then(mod => mod.MODULE)`.
  866. *
  867. * @see `Route#loadChildren`.
  868. * @publicApi
  869. */
  870. export declare type LoadChildrenCallback = () => Type<any> | NgModuleFactory<any> | Observable<Type<any>> | Promise<NgModuleFactory<any> | Type<any> | any>;
  871. /**
  872. * @description
  873. *
  874. * Information about any given navigation. This information can be gotten from the router at
  875. * any time using the `router.getCurrentNavigation()` method.
  876. *
  877. * @publicApi
  878. */
  879. export declare type Navigation = {
  880. /**
  881. * The ID of the current navigation.
  882. */
  883. id: number;
  884. /**
  885. * Target URL passed into the {@link Router#navigateByUrl} call before navigation. This is
  886. * the value before the router has parsed or applied redirects to it.
  887. */
  888. initialUrl: string | UrlTree;
  889. /**
  890. * The initial target URL after being parsed with {@link UrlSerializer.extract()}.
  891. */
  892. extractedUrl: UrlTree;
  893. /**
  894. * Extracted URL after redirects have been applied. This URL may not be available immediately,
  895. * therefore this property can be `undefined`. It is guaranteed to be set after the
  896. * {@link RoutesRecognized} event fires.
  897. */
  898. finalUrl?: UrlTree;
  899. /**
  900. * Identifies the trigger of the navigation.
  901. *
  902. * * 'imperative'--triggered by `router.navigateByUrl` or `router.navigate`.
  903. * * 'popstate'--triggered by a popstate event
  904. * * 'hashchange'--triggered by a hashchange event
  905. */
  906. trigger: 'imperative' | 'popstate' | 'hashchange';
  907. /**
  908. * The NavigationExtras used in this navigation. See {@link NavigationExtras} for more info.
  909. */
  910. extras: NavigationExtras;
  911. /**
  912. * Previously successful Navigation object. Only a single previous Navigation is available,
  913. * therefore this previous Navigation will always have a `null` value for `previousNavigation`.
  914. */
  915. previousNavigation: Navigation | null;
  916. };
  917. /**
  918. * @description
  919. *
  920. * Represents an event triggered when a navigation is canceled.
  921. *
  922. * @publicApi
  923. */
  924. export declare class NavigationCancel extends RouterEvent {
  925. /** @docsNotRequired */
  926. reason: string;
  927. constructor(
  928. /** @docsNotRequired */
  929. id: number,
  930. /** @docsNotRequired */
  931. url: string,
  932. /** @docsNotRequired */
  933. reason: string);
  934. /** @docsNotRequired */
  935. toString(): string;
  936. }
  937. /**
  938. * @description
  939. *
  940. * Represents an event triggered when a navigation ends successfully.
  941. *
  942. * @publicApi
  943. */
  944. export declare class NavigationEnd extends RouterEvent {
  945. /** @docsNotRequired */
  946. urlAfterRedirects: string;
  947. constructor(
  948. /** @docsNotRequired */
  949. id: number,
  950. /** @docsNotRequired */
  951. url: string,
  952. /** @docsNotRequired */
  953. urlAfterRedirects: string);
  954. /** @docsNotRequired */
  955. toString(): string;
  956. }
  957. /**
  958. * @description
  959. *
  960. * Represents an event triggered when a navigation fails due to an unexpected error.
  961. *
  962. * @publicApi
  963. */
  964. export declare class NavigationError extends RouterEvent {
  965. /** @docsNotRequired */
  966. error: any;
  967. constructor(
  968. /** @docsNotRequired */
  969. id: number,
  970. /** @docsNotRequired */
  971. url: string,
  972. /** @docsNotRequired */
  973. error: any);
  974. /** @docsNotRequired */
  975. toString(): string;
  976. }
  977. /**
  978. * @description
  979. *
  980. * Options that modify the navigation strategy.
  981. *
  982. * @publicApi
  983. */
  984. export declare interface NavigationExtras {
  985. /**
  986. * Enables relative navigation from the current ActivatedRoute.
  987. *
  988. * Configuration:
  989. *
  990. * ```
  991. * [{
  992. * path: 'parent',
  993. * component: ParentComponent,
  994. * children: [{
  995. * path: 'list',
  996. * component: ListComponent
  997. * },{
  998. * path: 'child',
  999. * component: ChildComponent
  1000. * }]
  1001. * }]
  1002. * ```
  1003. *
  1004. * Navigate to list route from child route:
  1005. *
  1006. * ```
  1007. * @Component({...})
  1008. * class ChildComponent {
  1009. * constructor(private router: Router, private route: ActivatedRoute) {}
  1010. *
  1011. * go() {
  1012. * this.router.navigate(['../list'], { relativeTo: this.route });
  1013. * }
  1014. * }
  1015. * ```
  1016. */
  1017. relativeTo?: ActivatedRoute | null;
  1018. /**
  1019. * Sets query parameters to the URL.
  1020. *
  1021. * ```
  1022. * // Navigate to /results?page=1
  1023. * this.router.navigate(['/results'], { queryParams: { page: 1 } });
  1024. * ```
  1025. */
  1026. queryParams?: Params | null;
  1027. /**
  1028. * Sets the hash fragment for the URL.
  1029. *
  1030. * ```
  1031. * // Navigate to /results#top
  1032. * this.router.navigate(['/results'], { fragment: 'top' });
  1033. * ```
  1034. */
  1035. fragment?: string;
  1036. /**
  1037. * DEPRECATED: Use `queryParamsHandling` instead to preserve
  1038. * query parameters for the next navigation.
  1039. *
  1040. * ```
  1041. * // Preserve query params from /results?page=1 to /view?page=1
  1042. * this.router.navigate(['/view'], { preserveQueryParams: true });
  1043. * ```
  1044. *
  1045. * @deprecated since v4
  1046. */
  1047. preserveQueryParams?: boolean;
  1048. /**
  1049. * Configuration strategy for how to handle query parameters for the next navigation.
  1050. *
  1051. * ```
  1052. * // from /results?page=1 to /view?page=1&page=2
  1053. * this.router.navigate(['/view'], { queryParams: { page: 2 }, queryParamsHandling: "merge" });
  1054. * ```
  1055. */
  1056. queryParamsHandling?: QueryParamsHandling | null;
  1057. /**
  1058. * Preserves the fragment for the next navigation
  1059. *
  1060. * ```
  1061. * // Preserve fragment from /results#top to /view#top
  1062. * this.router.navigate(['/view'], { preserveFragment: true });
  1063. * ```
  1064. */
  1065. preserveFragment?: boolean;
  1066. /**
  1067. * Navigates without pushing a new state into history.
  1068. *
  1069. * ```
  1070. * // Navigate silently to /view
  1071. * this.router.navigate(['/view'], { skipLocationChange: true });
  1072. * ```
  1073. */
  1074. skipLocationChange?: boolean;
  1075. /**
  1076. * Navigates while replacing the current state in history.
  1077. *
  1078. * ```
  1079. * // Navigate to /view
  1080. * this.router.navigate(['/view'], { replaceUrl: true });
  1081. * ```
  1082. */
  1083. replaceUrl?: boolean;
  1084. /**
  1085. * State passed to any navigation. This value will be accessible through the `extras` object
  1086. * returned from `router.getCurrentNavigation()` while a navigation is executing. Once a
  1087. * navigation completes, this value will be written to `history.state` when the `location.go`
  1088. * or `location.replaceState` method is called before activating of this route. Note that
  1089. * `history.state` will not pass an object equality test because the `navigationId` will be
  1090. * added to the state before being written.
  1091. *
  1092. * While `history.state` can accept any type of value, because the router adds the `navigationId`
  1093. * on each navigation, the `state` must always be an object.
  1094. */
  1095. state?: {
  1096. [k: string]: any;
  1097. };
  1098. }
  1099. /**
  1100. * @description
  1101. *
  1102. * Represents an event triggered when a navigation starts.
  1103. *
  1104. * @publicApi
  1105. */
  1106. export declare class NavigationStart extends RouterEvent {
  1107. /**
  1108. * Identifies the trigger of the navigation.
  1109. *
  1110. * * 'imperative'--triggered by `router.navigateByUrl` or `router.navigate`.
  1111. * * 'popstate'--triggered by a popstate event
  1112. * * 'hashchange'--triggered by a hashchange event
  1113. */
  1114. navigationTrigger?: 'imperative' | 'popstate' | 'hashchange';
  1115. /**
  1116. * This reflects the state object that was previously supplied to the pushState call. This is
  1117. * not null only when the navigation is triggered by a popstate event.
  1118. *
  1119. * The router assigns a navigationId to every router transition/navigation. Even when the user
  1120. * clicks on the back button in the browser, a new navigation id will be created. So from
  1121. * the perspective of the router, the router never "goes back". By using the `restoredState`
  1122. * and its navigationId, you can implement behavior that differentiates between creating new
  1123. * states
  1124. * and popstate events. In the latter case you can restore some remembered state (e.g., scroll
  1125. * position).
  1126. *
  1127. * See {@link NavigationExtras} for more information.
  1128. */
  1129. restoredState?: {
  1130. [k: string]: any;
  1131. navigationId: number;
  1132. } | null;
  1133. constructor(
  1134. /** @docsNotRequired */
  1135. id: number,
  1136. /** @docsNotRequired */
  1137. url: string,
  1138. /** @docsNotRequired */
  1139. navigationTrigger?: 'imperative' | 'popstate' | 'hashchange',
  1140. /** @docsNotRequired */
  1141. restoredState?: {
  1142. [k: string]: any;
  1143. navigationId: number;
  1144. } | null);
  1145. /** @docsNotRequired */
  1146. toString(): string;
  1147. }
  1148. /**
  1149. * @description
  1150. *
  1151. * Provides a preloading strategy that does not preload any modules.
  1152. *
  1153. * This strategy is enabled by default.
  1154. *
  1155. * @publicApi
  1156. */
  1157. export declare class NoPreloading implements PreloadingStrategy {
  1158. preload(route: Route, fn: () => Observable<any>): Observable<any>;
  1159. }
  1160. /**
  1161. * Store contextual information about a `RouterOutlet`
  1162. *
  1163. * @publicApi
  1164. */
  1165. export declare class OutletContext {
  1166. outlet: RouterOutlet | null;
  1167. route: ActivatedRoute | null;
  1168. resolver: ComponentFactoryResolver | null;
  1169. children: ChildrenOutletContexts;
  1170. attachRef: ComponentRef<any> | null;
  1171. }
  1172. /**
  1173. * Matrix and Query parameters.
  1174. *
  1175. * `ParamMap` makes it easier to work with parameters as they could have either a single value or
  1176. * multiple value. Because this should be known by the user, calling `get` or `getAll` returns the
  1177. * correct type (either `string` or `string[]`).
  1178. *
  1179. * The API is inspired by the URLSearchParams interface.
  1180. * see https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams
  1181. *
  1182. * @publicApi
  1183. */
  1184. export declare interface ParamMap {
  1185. has(name: string): boolean;
  1186. /**
  1187. * Return a single value for the given parameter name:
  1188. * - the value when the parameter has a single value,
  1189. * - the first value if the parameter has multiple values,
  1190. * - `null` when there is no such parameter.
  1191. */
  1192. get(name: string): string | null;
  1193. /**
  1194. * Return an array of values for the given parameter name.
  1195. *
  1196. * If there is no such parameter, an empty array is returned.
  1197. */
  1198. getAll(name: string): string[];
  1199. /** Name of the parameters */
  1200. readonly keys: string[];
  1201. }
  1202. /**
  1203. * A collection of parameters.
  1204. *
  1205. * @publicApi
  1206. */
  1207. export declare type Params = {
  1208. [key: string]: any;
  1209. };
  1210. /**
  1211. * @description
  1212. *
  1213. * Provides a preloading strategy that preloads all modules as quickly as possible.
  1214. *
  1215. * ```
  1216. * RouteModule.forRoot(ROUTES, {preloadingStrategy: PreloadAllModules})
  1217. * ```
  1218. *
  1219. * @publicApi
  1220. */
  1221. export declare class PreloadAllModules implements PreloadingStrategy {
  1222. preload(route: Route, fn: () => Observable<any>): Observable<any>;
  1223. }
  1224. /**
  1225. * @description
  1226. *
  1227. * Provides a preloading strategy.
  1228. *
  1229. * @publicApi
  1230. */
  1231. export declare abstract class PreloadingStrategy {
  1232. abstract preload(route: Route, fn: () => Observable<any>): Observable<any>;
  1233. }
  1234. /**
  1235. * @description
  1236. *
  1237. * Name of the primary outlet.
  1238. *
  1239. * @publicApi
  1240. */
  1241. export declare const PRIMARY_OUTLET = "primary";
  1242. /**
  1243. * @description
  1244. *
  1245. * Registers routes.
  1246. *
  1247. * @usageNotes
  1248. * ### Example
  1249. *
  1250. * ```
  1251. * @NgModule({
  1252. * imports: [RouterModule.forChild(ROUTES)],
  1253. * providers: [provideRoutes(EXTRA_ROUTES)]
  1254. * })
  1255. * class MyNgModule {}
  1256. * ```
  1257. *
  1258. * @publicApi
  1259. */
  1260. export declare function provideRoutes(routes: Routes): any;
  1261. /**
  1262. *
  1263. * How to handle query parameters in a router link.
  1264. * One of:
  1265. * - `merge` : Merge new with current parameters.
  1266. * - `preserve` : Preserve current parameters.
  1267. *
  1268. * @see `RouterLink#queryParamsHandling`.
  1269. * @publicApi
  1270. */
  1271. declare type QueryParamsHandling = 'merge' | 'preserve' | '';
  1272. /**
  1273. * @description
  1274. *
  1275. * Interface that classes can implement to be a data provider.
  1276. *
  1277. * ```
  1278. * class Backend {
  1279. * fetchTeam(id: string) {
  1280. * return 'someTeam';
  1281. * }
  1282. * }
  1283. *
  1284. * @Injectable()
  1285. * class TeamResolver implements Resolve<Team> {
  1286. * constructor(private backend: Backend) {}
  1287. *
  1288. * resolve(
  1289. * route: ActivatedRouteSnapshot,
  1290. * state: RouterStateSnapshot
  1291. * ): Observable<any>|Promise<any>|any {
  1292. * return this.backend.fetchTeam(route.params.id);
  1293. * }
  1294. * }
  1295. *
  1296. * @NgModule({
  1297. * imports: [
  1298. * RouterModule.forRoot([
  1299. * {
  1300. * path: 'team/:id',
  1301. * component: TeamComponent,
  1302. * resolve: {
  1303. * team: TeamResolver
  1304. * }
  1305. * }
  1306. * ])
  1307. * ],
  1308. * providers: [TeamResolver]
  1309. * })
  1310. * class AppModule {}
  1311. * ```
  1312. *
  1313. * You can alternatively provide a function with the `resolve` signature:
  1314. *
  1315. * ```
  1316. * @NgModule({
  1317. * imports: [
  1318. * RouterModule.forRoot([
  1319. * {
  1320. * path: 'team/:id',
  1321. * component: TeamComponent,
  1322. * resolve: {
  1323. * team: 'teamResolver'
  1324. * }
  1325. * }
  1326. * ])
  1327. * ],
  1328. * providers: [
  1329. * {
  1330. * provide: 'teamResolver',
  1331. * useValue: (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) => 'team'
  1332. * }
  1333. * ]
  1334. * })
  1335. * class AppModule {}
  1336. * ```
  1337. *
  1338. * @publicApi
  1339. */
  1340. export declare interface Resolve<T> {
  1341. resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<T> | Promise<T> | T;
  1342. }
  1343. /**
  1344. *
  1345. * Represents the resolved data associated with a particular route.
  1346. *
  1347. * @see `Route#resolve`.
  1348. *
  1349. * @publicApi
  1350. */
  1351. export declare type ResolveData = {
  1352. [name: string]: any;
  1353. };
  1354. /**
  1355. * @description
  1356. *
  1357. * Represents the end of the Resolve phase of routing. See note on
  1358. * `ResolveStart` for use of this experimental API.
  1359. *
  1360. * @publicApi
  1361. */
  1362. export declare class ResolveEnd extends RouterEvent {
  1363. /** @docsNotRequired */
  1364. urlAfterRedirects: string;
  1365. /** @docsNotRequired */
  1366. state: RouterStateSnapshot;
  1367. constructor(
  1368. /** @docsNotRequired */
  1369. id: number,
  1370. /** @docsNotRequired */
  1371. url: string,
  1372. /** @docsNotRequired */
  1373. urlAfterRedirects: string,
  1374. /** @docsNotRequired */
  1375. state: RouterStateSnapshot);
  1376. toString(): string;
  1377. }
  1378. /**
  1379. * @description
  1380. *
  1381. * Represents the start of the Resolve phase of routing. The timing of this
  1382. * event may change, thus it's experimental. In the current iteration it will run
  1383. * in the "resolve" phase whether there's things to resolve or not. In the future this
  1384. * behavior may change to only run when there are things to be resolved.
  1385. *
  1386. * @publicApi
  1387. */
  1388. export declare class ResolveStart extends RouterEvent {
  1389. /** @docsNotRequired */
  1390. urlAfterRedirects: string;
  1391. /** @docsNotRequired */
  1392. state: RouterStateSnapshot;
  1393. constructor(
  1394. /** @docsNotRequired */
  1395. id: number,
  1396. /** @docsNotRequired */
  1397. url: string,
  1398. /** @docsNotRequired */
  1399. urlAfterRedirects: string,
  1400. /** @docsNotRequired */
  1401. state: RouterStateSnapshot);
  1402. toString(): string;
  1403. }
  1404. /**
  1405. * A configuration object that defines a single route.
  1406. * A set of routes are collected in a `Routes` array to define a `Router` configuration.
  1407. * The router attempts to match segments of a given URL against each route,
  1408. * using the configuration options defined in this object.
  1409. *
  1410. * Supports static, parameterized, redirect, and wildcard routes, as well as
  1411. * custom route data and resolve methods.
  1412. *
  1413. * For detailed usage information, see the [Routing Guide](guide/router).
  1414. *
  1415. * @usageNotes
  1416. *
  1417. * ### Simple Configuration
  1418. *
  1419. * The following route specifies that when navigating to, for example,
  1420. * `/team/11/user/bob`, the router creates the 'Team' component
  1421. * with the 'User' child component in it.
  1422. *
  1423. * ```
  1424. * [{
  1425. * path: 'team/:id',
  1426. * component: Team,
  1427. * children: [{
  1428. * path: 'user/:name',
  1429. * component: User
  1430. * }]
  1431. * }]
  1432. * ```
  1433. *
  1434. * ### Multiple Outlets
  1435. *
  1436. * The following route creates sibling components with multiple outlets.
  1437. * When navigating to `/team/11(aux:chat/jim)`, the router creates the 'Team' component next to
  1438. * the 'Chat' component. The 'Chat' component is placed into the 'aux' outlet.
  1439. *
  1440. * ```
  1441. * [{
  1442. * path: 'team/:id',
  1443. * component: Team
  1444. * }, {
  1445. * path: 'chat/:user',
  1446. * component: Chat
  1447. * outlet: 'aux'
  1448. * }]
  1449. * ```
  1450. *
  1451. * ### Wild Cards
  1452. *
  1453. * The following route uses wild-card notation to specify a component
  1454. * that is always instantiated regardless of where you navigate to.
  1455. *
  1456. * ```
  1457. * [{
  1458. * path: '**',
  1459. * component: WildcardComponent
  1460. * }]
  1461. * ```
  1462. *
  1463. * ### Redirects
  1464. *
  1465. * The following route uses the `redirectTo` property to ignore a segment of
  1466. * a given URL when looking for a child path.
  1467. *
  1468. * When navigating to '/team/11/legacy/user/jim', the router changes the URL segment
  1469. * '/team/11/legacy/user/jim' to '/team/11/user/jim', and then instantiates
  1470. * the Team component with the User child component in it.
  1471. *
  1472. * ```
  1473. * [{
  1474. * path: 'team/:id',
  1475. * component: Team,
  1476. * children: [{
  1477. * path: 'legacy/user/:name',
  1478. * redirectTo: 'user/:name'
  1479. * }, {
  1480. * path: 'user/:name',
  1481. * component: User
  1482. * }]
  1483. * }]
  1484. * ```
  1485. *
  1486. * The redirect path can be relative, as shown in this example, or absolute.
  1487. * If we change the `redirectTo` value in the example to the absolute URL segment '/user/:name',
  1488. * the result URL is also absolute, '/user/jim'.
  1489. * ### Empty Path
  1490. *
  1491. * Empty-path route configurations can be used to instantiate components that do not 'consume'
  1492. * any URL segments.
  1493. *
  1494. * In the following configuration, when navigating to
  1495. * `/team/11`, the router instantiates the 'AllUsers' component.
  1496. *
  1497. * ```
  1498. * [{
  1499. * path: 'team/:id',
  1500. * component: Team,
  1501. * children: [{
  1502. * path: '',
  1503. * component: AllUsers
  1504. * }, {
  1505. * path: 'user/:name',
  1506. * component: User
  1507. * }]
  1508. * }]
  1509. * ```
  1510. *
  1511. * Empty-path routes can have children. In the following example, when navigating
  1512. * to `/team/11/user/jim`, the router instantiates the wrapper component with
  1513. * the user component in it.
  1514. *
  1515. * Note that an empty path route inherits its parent's parameters and data.
  1516. *
  1517. * ```
  1518. * [{
  1519. * path: 'team/:id',
  1520. * component: Team,
  1521. * children: [{
  1522. * path: '',
  1523. * component: WrapperCmp,
  1524. * children: [{
  1525. * path: 'user/:name',
  1526. * component: User
  1527. * }]
  1528. * }]
  1529. * }]
  1530. * ```
  1531. *
  1532. * ### Matching Strategy
  1533. *
  1534. * The default path-match strategy is 'prefix', which means that the router
  1535. * checks URL elements from the left to see if the URL matches a specified path.
  1536. * For example, '/team/11/user' matches 'team/:id'.
  1537. *
  1538. * ```
  1539. * [{
  1540. * path: '',
  1541. * pathMatch: 'prefix', //default
  1542. * redirectTo: 'main'
  1543. * }, {
  1544. * path: 'main',
  1545. * component: Main
  1546. * }]
  1547. * ```
  1548. *
  1549. * You can specify the path-match strategy 'full' to make sure that the path
  1550. * covers the whole unconsumed URL. It is important to do this when redirecting
  1551. * empty-path routes. Otherwise, because an empty path is a prefix of any URL,
  1552. * the router would apply the redirect even when navigating to the redirect destination,
  1553. * creating an endless loop.
  1554. *
  1555. * In the following example, supplying the 'full' `patchMatch` strategy ensures
  1556. * that the router applies the redirect if and only if navigating to '/'.
  1557. *
  1558. * ```
  1559. * [{
  1560. * path: '',
  1561. * pathMatch: 'full',
  1562. * redirectTo: 'main'
  1563. * }, {
  1564. * path: 'main',
  1565. * component: Main
  1566. * }]
  1567. * ```
  1568. *
  1569. * ### Componentless Routes
  1570. *
  1571. * You can share parameters between sibling components.
  1572. * For example, suppose that two sibling components should go next to each other,
  1573. * and both of them require an ID parameter. You can accomplish this using a route
  1574. * that does not specify a component at the top level.
  1575. *
  1576. * In the following example, 'ChildCmp' and 'AuxCmp' are siblings.
  1577. * When navigating to 'parent/10/(a//aux:b)', the route instantiates
  1578. * the main child and aux child components next to each other.
  1579. * For this to work, the application component must have the primary and aux outlets defined.
  1580. *
  1581. * ```
  1582. * [{
  1583. * path: 'parent/:id',
  1584. * children: [
  1585. * { path: 'a', component: MainChild },
  1586. * { path: 'b', component: AuxChild, outlet: 'aux' }
  1587. * ]
  1588. * }]
  1589. * ```
  1590. *
  1591. * The router merges the parameters, data, and resolve of the componentless
  1592. * parent into the parameters, data, and resolve of the children.
  1593. *
  1594. * This is especially useful when child components are defined
  1595. * with an empty path string, as in the following example.
  1596. * With this configuration, navigating to '/parent/10' creates
  1597. * the main child and aux components.
  1598. *
  1599. * ```
  1600. * [{
  1601. * path: 'parent/:id',
  1602. * children: [
  1603. * { path: '', component: MainChild },
  1604. * { path: '', component: AuxChild, outlet: 'aux' }
  1605. * ]
  1606. * }]
  1607. * ```
  1608. *
  1609. * ### Lazy Loading
  1610. *
  1611. * Lazy loading speeds up application load time by splitting the application
  1612. * into multiple bundles and loading them on demand.
  1613. * To use lazy loading, provide the `loadChildren` property instead of the `children` property.
  1614. *
  1615. * Given the following example route, the router uses the registered
  1616. * `NgModuleFactoryLoader` to fetch an NgModule associated with 'team'.
  1617. * It then extracts the set of routes defined in that NgModule,
  1618. * and transparently adds those routes to the main configuration.
  1619. *
  1620. * ```
  1621. * [{
  1622. * path: 'team/:id',
  1623. * component: Team,
  1624. * loadChildren: 'team'
  1625. * }]
  1626. * ```
  1627. *
  1628. * @publicApi
  1629. */
  1630. export declare interface Route {
  1631. /**
  1632. * The path to match against, a URL string that uses router matching notation.
  1633. * Can be a wild card (`**`) that matches any URL (see Usage Notes below).
  1634. * Default is "/" (the root path).
  1635. */
  1636. path?: string;
  1637. /**
  1638. * The path-matching strategy, one of 'prefix' or 'full'.
  1639. * Default is 'prefix'.
  1640. *
  1641. * By default, the router checks URL elements from the left to see if the URL
  1642. * matches a given path, and stops when there is a match. For example,
  1643. * '/team/11/user' matches 'team/:id'.
  1644. *
  1645. * The path-match strategy 'full' matches against the entire URL.
  1646. * It is important to do this when redirecting empty-path routes.
  1647. * Otherwise, because an empty path is a prefix of any URL,
  1648. * the router would apply the redirect even when navigating
  1649. * to the redirect destination, creating an endless loop.
  1650. *
  1651. */
  1652. pathMatch?: string;
  1653. /**
  1654. * A URL-matching function to use as a custom strategy for path matching.
  1655. * If present, supersedes `path` and `pathMatch`.
  1656. */
  1657. matcher?: UrlMatcher;
  1658. /**
  1659. * The component to instantiate when the path matches.
  1660. * Can be empty if child routes specify components.
  1661. */
  1662. component?: Type<any>;
  1663. /**
  1664. * A URL to which to redirect when a the path matches.
  1665. * Absolute if the URL begins with a slash (/), otherwise relative to the path URL.
  1666. * When not present, router does not redirect.
  1667. */
  1668. redirectTo?: string;
  1669. /**
  1670. * Name of a `RouterOutlet` object where the component can be placed
  1671. * when the path matches.
  1672. */
  1673. outlet?: string;
  1674. /**
  1675. * An array of dependency-injection tokens used to look up `CanActivate()`
  1676. * handlers, in order to determine if the current user is allowed to
  1677. * activate the component. By default, any user can activate.
  1678. */
  1679. canActivate?: any[];
  1680. /**
  1681. * An array of DI tokens used to look up `CanActivateChild()` handlers,
  1682. * in order to determine if the current user is allowed to activate
  1683. * a child of the component. By default, any user can activate a child.
  1684. */
  1685. canActivateChild?: any[];
  1686. /**
  1687. * An array of DI tokens used to look up `CanDeactivate()`
  1688. * handlers, in order to determine if the current user is allowed to
  1689. * deactivate the component. By default, any user can deactivate.
  1690. *
  1691. */
  1692. canDeactivate?: any[];
  1693. /**
  1694. * An array of DI tokens used to look up `CanLoad()`
  1695. * handlers, in order to determine if the current user is allowed to
  1696. * load the component. By default, any user can load.
  1697. */
  1698. canLoad?: any[];
  1699. /**
  1700. * Additional developer-defined data provided to the component via
  1701. * `ActivatedRoute`. By default, no additional data is passed.
  1702. */
  1703. data?: Data;
  1704. /**
  1705. * A map of DI tokens used to look up data resolvers. See `Resolve`.
  1706. */
  1707. resolve?: ResolveData;
  1708. /**
  1709. * An array of child `Route` objects that specifies a nested route
  1710. * configuration.
  1711. */
  1712. children?: Routes;
  1713. /**
  1714. * A `LoadChildren` object specifying lazy-loaded child routes.
  1715. */
  1716. loadChildren?: LoadChildren;
  1717. /**
  1718. * Defines when guards and resolvers will be run. One of
  1719. * - `paramsOrQueryParamsChange` : Run when query parameters change.
  1720. * - `always` : Run on every execution.
  1721. * By default, guards and resolvers run only when the matrix
  1722. * parameters of the route change.
  1723. */
  1724. runGuardsAndResolvers?: RunGuardsAndResolvers;
  1725. }
  1726. /**
  1727. * @description
  1728. *
  1729. * Represents an event triggered when a route has been lazy loaded.
  1730. *
  1731. * @publicApi
  1732. */
  1733. export declare class RouteConfigLoadEnd {
  1734. /** @docsNotRequired */
  1735. route: Route;
  1736. constructor(
  1737. /** @docsNotRequired */
  1738. route: Route);
  1739. toString(): string;
  1740. }
  1741. /**
  1742. * @description
  1743. *
  1744. * Represents an event triggered before lazy loading a route config.
  1745. *
  1746. * @publicApi
  1747. */
  1748. export declare class RouteConfigLoadStart {
  1749. /** @docsNotRequired */
  1750. route: Route;
  1751. constructor(
  1752. /** @docsNotRequired */
  1753. route: Route);
  1754. toString(): string;
  1755. }
  1756. /**
  1757. * @description
  1758. *
  1759. * An NgModule that provides navigation and URL manipulation capabilities.
  1760. *
  1761. * @see `Route`.
  1762. * @see [Routing and Navigation Guide](guide/router).
  1763. *
  1764. * @ngModule RouterModule
  1765. *
  1766. * @publicApi
  1767. */
  1768. export declare class Router {
  1769. private rootComponentType;
  1770. private urlSerializer;
  1771. private rootContexts;
  1772. private location;
  1773. config: Routes;
  1774. private currentUrlTree;
  1775. private rawUrlTree;
  1776. private browserUrlTree;
  1777. private readonly transitions;
  1778. private navigations;
  1779. private lastSuccessfulNavigation;
  1780. private currentNavigation;
  1781. private locationSubscription;
  1782. private navigationId;
  1783. private configLoader;
  1784. private ngModule;
  1785. private console;
  1786. private isNgZoneEnabled;
  1787. /**
  1788. * An event stream for routing events in this NgModule.
  1789. */
  1790. readonly events: Observable<Event>;
  1791. /**
  1792. * The current state of routing in this NgModule.
  1793. */
  1794. readonly routerState: RouterState;
  1795. /**
  1796. * A handler for navigation errors in this NgModule.
  1797. */
  1798. errorHandler: ErrorHandler;
  1799. /**
  1800. * Malformed uri error handler is invoked when `Router.parseUrl(url)` throws an
  1801. * error due to containing an invalid character. The most common case would be a `%` sign
  1802. * that's not encoded and is not part of a percent encoded sequence.
  1803. */
  1804. malformedUriErrorHandler: (error: URIError, urlSerializer: UrlSerializer, url: string) => UrlTree;
  1805. /**
  1806. * True if at least one navigation event has occurred,
  1807. * false otherwise.
  1808. */
  1809. navigated: boolean;
  1810. private lastSuccessfulId;
  1811. /**
  1812. * Extracts and merges URLs. Used for AngularJS to Angular migrations.
  1813. */
  1814. urlHandlingStrategy: UrlHandlingStrategy;
  1815. /**
  1816. * The strategy for re-using routes.
  1817. */
  1818. routeReuseStrategy: RouteReuseStrategy;
  1819. /**
  1820. * How to handle a navigation request to the current URL. One of:
  1821. * - `'ignore'` : The router ignores the request.
  1822. * - `'reload'` : The router reloads the URL. Use to implement a "refresh" feature.
  1823. */
  1824. onSameUrlNavigation: 'reload' | 'ignore';
  1825. /**
  1826. * How to merge parameters, data, and resolved data from parent to child
  1827. * routes. One of:
  1828. *
  1829. * - `'emptyOnly'` : Inherit parent parameters, data, and resolved data
  1830. * for path-less or component-less routes.
  1831. * - `'always'` : Inherit parent parameters, data, and resolved data
  1832. * for all child routes.
  1833. */
  1834. paramsInheritanceStrategy: 'emptyOnly' | 'always';
  1835. /**
  1836. * Defines when the router updates the browser URL. The default behavior is to update after
  1837. * successful navigation. However, some applications may prefer a mode where the URL gets
  1838. * updated at the beginning of navigation. The most common use case would be updating the
  1839. * URL early so if navigation fails, you can show an error message with the URL that failed.
  1840. * Available options are:
  1841. *
  1842. * - `'deferred'`, the default, updates the browser URL after navigation has finished.
  1843. * - `'eager'`, updates browser URL at the beginning of navigation.
  1844. */
  1845. urlUpdateStrategy: 'deferred' | 'eager';
  1846. /**
  1847. * See {@link RouterModule} for more information.
  1848. */
  1849. relativeLinkResolution: 'legacy' | 'corrected';
  1850. /**
  1851. * Creates the router service.
  1852. */
  1853. constructor(rootComponentType: Type<any> | null, urlSerializer: UrlSerializer, rootContexts: ChildrenOutletContexts, location: Location, injector: Injector, loader: NgModuleFactoryLoader, compiler: Compiler, config: Routes);
  1854. private setupNavigations;
  1855. private getTransition;
  1856. private setTransition;
  1857. /**
  1858. * Sets up the location change listener and performs the initial navigation.
  1859. */
  1860. initialNavigation(): void;
  1861. /**
  1862. * Sets up the location change listener.
  1863. */
  1864. setUpLocationChangeListener(): void;
  1865. /** The current URL. */
  1866. readonly url: string;
  1867. /** The current Navigation object if one exists */
  1868. getCurrentNavigation(): Navigation | null;
  1869. /**
  1870. * Resets the configuration used for navigation and generating links.
  1871. *
  1872. * @param config The route array for the new configuration.
  1873. *
  1874. * @usageNotes
  1875. *
  1876. * ```
  1877. * router.resetConfig([
  1878. * { path: 'team/:id', component: TeamCmp, children: [
  1879. * { path: 'simple', component: SimpleCmp },
  1880. * { path: 'user/:name', component: UserCmp }
  1881. * ]}
  1882. * ]);
  1883. * ```
  1884. */
  1885. resetConfig(config: Routes): void;
  1886. /** @docsNotRequired */
  1887. ngOnDestroy(): void;
  1888. /** Disposes of the router. */
  1889. dispose(): void;
  1890. /**
  1891. * Applies an array of commands to the current URL tree and creates a new URL tree.
  1892. *
  1893. * When given an activate route, applies the given commands starting from the route.
  1894. * When not given a route, applies the given command starting from the root.
  1895. *
  1896. * @param commands An array of commands to apply.
  1897. * @param navigationExtras
  1898. * @returns The new URL tree.
  1899. *
  1900. * @usageNotes
  1901. *
  1902. * ```
  1903. * // create /team/33/user/11
  1904. * router.createUrlTree(['/team', 33, 'user', 11]);
  1905. *
  1906. * // create /team/33;expand=true/user/11
  1907. * router.createUrlTree(['/team', 33, {expand: true}, 'user', 11]);
  1908. *
  1909. * // you can collapse static segments like this (this works only with the first passed-in value):
  1910. * router.createUrlTree(['/team/33/user', userId]);
  1911. *
  1912. * // If the first segment can contain slashes, and you do not want the router to split it, you
  1913. * // can do the following:
  1914. *
  1915. * router.createUrlTree([{segmentPath: '/one/two'}]);
  1916. *
  1917. * // create /team/33/(user/11//right:chat)
  1918. * router.createUrlTree(['/team', 33, {outlets: {primary: 'user/11', right: 'chat'}}]);
  1919. *
  1920. * // remove the right secondary node
  1921. * router.createUrlTree(['/team', 33, {outlets: {primary: 'user/11', right: null}}]);
  1922. *
  1923. * // assuming the current url is `/team/33/user/11` and the route points to `user/11`
  1924. *
  1925. * // navigate to /team/33/user/11/details
  1926. * router.createUrlTree(['details'], {relativeTo: route});
  1927. *
  1928. * // navigate to /team/33/user/22
  1929. * router.createUrlTree(['../22'], {relativeTo: route});
  1930. *
  1931. * // navigate to /team/44/user/22
  1932. * router.createUrlTree(['../../team/44/user/22'], {relativeTo: route});
  1933. * ```
  1934. */
  1935. createUrlTree(commands: any[], navigationExtras?: NavigationExtras): UrlTree;
  1936. /**
  1937. * Navigate based on the provided URL, which must be absolute.
  1938. *
  1939. * @param url An absolute URL. The function does not apply any delta to the current URL.
  1940. * @param extras An object containing properties that modify the navigation strategy.
  1941. * The function ignores any properties in the `NavigationExtras` that would change the
  1942. * provided URL.
  1943. *
  1944. * @returns A Promise that resolves to 'true' when navigation succeeds,
  1945. * to 'false' when navigation fails, or is rejected on error.
  1946. *
  1947. * @usageNotes
  1948. *
  1949. * ### Example
  1950. *
  1951. * ```
  1952. * router.navigateByUrl("/team/33/user/11");
  1953. *
  1954. * // Navigate without updating the URL
  1955. * router.navigateByUrl("/team/33/user/11", { skipLocationChange: true });
  1956. * ```
  1957. *
  1958. */
  1959. navigateByUrl(url: string | UrlTree, extras?: NavigationExtras): Promise<boolean>;
  1960. /**
  1961. * Navigate based on the provided array of commands and a starting point.
  1962. * If no starting route is provided, the navigation is absolute.
  1963. *
  1964. * Returns a promise that:
  1965. * - resolves to 'true' when navigation succeeds,
  1966. * - resolves to 'false' when navigation fails,
  1967. * - is rejected when an error happens.
  1968. *
  1969. * @usageNotes
  1970. *
  1971. * ### Example
  1972. *
  1973. * ```
  1974. * router.navigate(['team', 33, 'user', 11], {relativeTo: route});
  1975. *
  1976. * // Navigate without updating the URL
  1977. * router.navigate(['team', 33, 'user', 11], {relativeTo: route, skipLocationChange: true});
  1978. * ```
  1979. *
  1980. * The first parameter of `navigate()` is a delta to be applied to the current URL
  1981. * or the one provided in the `relativeTo` property of the second parameter (the
  1982. * `NavigationExtras`).
  1983. *
  1984. * In order to affect this browser's `history.state` entry, the `state`
  1985. * parameter can be passed. This must be an object because the router
  1986. * will add the `navigationId` property to this object before creating
  1987. * the new history item.
  1988. */
  1989. navigate(commands: any[], extras?: NavigationExtras): Promise<boolean>;
  1990. /** Serializes a `UrlTree` into a string */
  1991. serializeUrl(url: UrlTree): string;
  1992. /** Parses a string into a `UrlTree` */
  1993. parseUrl(url: string): UrlTree;
  1994. /** Returns whether the url is activated */
  1995. isActive(url: string | UrlTree, exact: boolean): boolean;
  1996. private removeEmptyProps;
  1997. private processNavigations;
  1998. private scheduleNavigation;
  1999. private setBrowserUrl;
  2000. private resetStateAndUrl;
  2001. private resetUrlToCurrentUrlTree;
  2002. }
  2003. /**
  2004. * @description
  2005. *
  2006. * Is used in DI to configure the router.
  2007. *
  2008. * @publicApi
  2009. */
  2010. export declare const ROUTER_CONFIGURATION: InjectionToken<ExtraOptions>;
  2011. /**
  2012. * A token for the router initializer that will be called after the app is bootstrapped.
  2013. *
  2014. * @publicApi
  2015. */
  2016. export declare const ROUTER_INITIALIZER: InjectionToken<(compRef: ComponentRef<any>) => void>;
  2017. /**
  2018. * @description
  2019. *
  2020. * Provides a way to customize when activated routes get reused.
  2021. *
  2022. * @publicApi
  2023. */
  2024. export declare abstract class RouteReuseStrategy {
  2025. /** Determines if this route (and its subtree) should be detached to be reused later */
  2026. abstract shouldDetach(route: ActivatedRouteSnapshot): boolean;
  2027. /**
  2028. * Stores the detached route.
  2029. *
  2030. * Storing a `null` value should erase the previously stored value.
  2031. */
  2032. abstract store(route: ActivatedRouteSnapshot, handle: DetachedRouteHandle | null): void;
  2033. /** Determines if this route (and its subtree) should be reattached */
  2034. abstract shouldAttach(route: ActivatedRouteSnapshot): boolean;
  2035. /** Retrieves the previously stored route */
  2036. abstract retrieve(route: ActivatedRouteSnapshot): DetachedRouteHandle | null;
  2037. /** Determines if a route should be reused */
  2038. abstract shouldReuseRoute(future: ActivatedRouteSnapshot, curr: ActivatedRouteSnapshot): boolean;
  2039. }
  2040. /**
  2041. * @description
  2042. *
  2043. * Base for events the Router goes through, as opposed to events tied to a specific
  2044. * Route. `RouterEvent`s will only be fired one time for any given navigation.
  2045. *
  2046. * Example:
  2047. *
  2048. * ```
  2049. * class MyService {
  2050. * constructor(public router: Router, logger: Logger) {
  2051. * router.events.pipe(
  2052. * filter(e => e instanceof RouterEvent)
  2053. * ).subscribe(e => {
  2054. * logger.log(e.id, e.url);
  2055. * });
  2056. * }
  2057. * }
  2058. * ```
  2059. *
  2060. * @publicApi
  2061. */
  2062. export declare class RouterEvent {
  2063. /** @docsNotRequired */
  2064. id: number;
  2065. /** @docsNotRequired */
  2066. url: string;
  2067. constructor(
  2068. /** @docsNotRequired */
  2069. id: number,
  2070. /** @docsNotRequired */
  2071. url: string);
  2072. }
  2073. /**
  2074. * @description
  2075. *
  2076. * Lets you link to specific routes in your app.
  2077. *
  2078. * Consider the following route configuration:
  2079. * `[{ path: 'user/:name', component: UserCmp }]`.
  2080. * When linking to this `user/:name` route, you use the `RouterLink` directive.
  2081. *
  2082. * If the link is static, you can use the directive as follows:
  2083. * `<a routerLink="/user/bob">link to user component</a>`
  2084. *
  2085. * If you use dynamic values to generate the link, you can pass an array of path
  2086. * segments, followed by the params for each segment.
  2087. *
  2088. * For instance `['/team', teamId, 'user', userName, {details: true}]`
  2089. * means that we want to generate a link to `/team/11/user/bob;details=true`.
  2090. *
  2091. * Multiple static segments can be merged into one
  2092. * (e.g., `['/team/11/user', userName, {details: true}]`).
  2093. *
  2094. * The first segment name can be prepended with `/`, `./`, or `../`:
  2095. * * If the first segment begins with `/`, the router will look up the route from the root of the
  2096. * app.
  2097. * * If the first segment begins with `./`, or doesn't begin with a slash, the router will
  2098. * instead look in the children of the current activated route.
  2099. * * And if the first segment begins with `../`, the router will go up one level.
  2100. *
  2101. * You can set query params and fragment as follows:
  2102. *
  2103. * ```
  2104. * <a [routerLink]="['/user/bob']" [queryParams]="{debug: true}" fragment="education">
  2105. * link to user component
  2106. * </a>
  2107. * ```
  2108. * RouterLink will use these to generate this link: `/user/bob#education?debug=true`.
  2109. *
  2110. * (Deprecated in v4.0.0 use `queryParamsHandling` instead) You can also tell the
  2111. * directive to preserve the current query params and fragment:
  2112. *
  2113. * ```
  2114. * <a [routerLink]="['/user/bob']" preserveQueryParams preserveFragment>
  2115. * link to user component
  2116. * </a>
  2117. * ```
  2118. *
  2119. * You can tell the directive how to handle queryParams. Available options are:
  2120. * - `'merge'`: merge the queryParams into the current queryParams
  2121. * - `'preserve'`: preserve the current queryParams
  2122. * - default/`''`: use the queryParams only
  2123. *
  2124. * Same options for {@link NavigationExtras#queryParamsHandling
  2125. * NavigationExtras#queryParamsHandling}.
  2126. *
  2127. * ```
  2128. * <a [routerLink]="['/user/bob']" [queryParams]="{debug: true}" queryParamsHandling="merge">
  2129. * link to user component
  2130. * </a>
  2131. * ```
  2132. *
  2133. * You can provide a `state` value to be persisted to the browser's History.state
  2134. * property (See https://developer.mozilla.org/en-US/docs/Web/API/History#Properties). It's
  2135. * used as follows:
  2136. *
  2137. * ```
  2138. * <a [routerLink]="['/user/bob']" [state]="{tracingId: 123}">
  2139. * link to user component
  2140. * </a>
  2141. * ```
  2142. *
  2143. * And later the value can be read from the router through `router.getCurrentNavigation`.
  2144. * For example, to capture the `tracingId` above during the `NavigationStart` event:
  2145. *
  2146. * ```
  2147. * // Get NavigationStart events
  2148. * router.events.pipe(filter(e => e instanceof NavigationStart)).subscribe(e => {
  2149. * const navigation = router.getCurrentNavigation();
  2150. * tracingService.trace({id: navigation.extras.state.tracingId});
  2151. * });
  2152. * ```
  2153. *
  2154. * The router link directive always treats the provided input as a delta to the current url.
  2155. *
  2156. * For instance, if the current url is `/user/(box//aux:team)`.
  2157. *
  2158. * Then the following link `<a [routerLink]="['/user/jim']">Jim</a>` will generate the link
  2159. * `/user/(jim//aux:team)`.
  2160. *
  2161. * See {@link Router#createUrlTree createUrlTree} for more information.
  2162. *
  2163. * @ngModule RouterModule
  2164. *
  2165. * @publicApi
  2166. */
  2167. export declare class RouterLink {
  2168. private router;
  2169. private route;
  2170. queryParams: {
  2171. [k: string]: any;
  2172. };
  2173. fragment: string;
  2174. queryParamsHandling: QueryParamsHandling;
  2175. preserveFragment: boolean;
  2176. skipLocationChange: boolean;
  2177. replaceUrl: boolean;
  2178. state?: {
  2179. [k: string]: any;
  2180. };
  2181. private commands;
  2182. private preserve;
  2183. constructor(router: Router, route: ActivatedRoute, tabIndex: string, renderer: Renderer2, el: ElementRef);
  2184. routerLink: any[] | string;
  2185. /**
  2186. * @deprecated 4.0.0 use `queryParamsHandling` instead.
  2187. */
  2188. preserveQueryParams: boolean;
  2189. onClick(): boolean;
  2190. readonly urlTree: UrlTree;
  2191. }
  2192. /**
  2193. *
  2194. * @description
  2195. *
  2196. * Lets you add a CSS class to an element when the link's route becomes active.
  2197. *
  2198. * This directive lets you add a CSS class to an element when the link's route
  2199. * becomes active.
  2200. *
  2201. * Consider the following example:
  2202. *
  2203. * ```
  2204. * <a routerLink="/user/bob" routerLinkActive="active-link">Bob</a>
  2205. * ```
  2206. *
  2207. * When the url is either '/user' or '/user/bob', the active-link class will
  2208. * be added to the `a` tag. If the url changes, the class will be removed.
  2209. *
  2210. * You can set more than one class, as follows:
  2211. *
  2212. * ```
  2213. * <a routerLink="/user/bob" routerLinkActive="class1 class2">Bob</a>
  2214. * <a routerLink="/user/bob" [routerLinkActive]="['class1', 'class2']">Bob</a>
  2215. * ```
  2216. *
  2217. * You can configure RouterLinkActive by passing `exact: true`. This will add the classes
  2218. * only when the url matches the link exactly.
  2219. *
  2220. * ```
  2221. * <a routerLink="/user/bob" routerLinkActive="active-link" [routerLinkActiveOptions]="{exact:
  2222. * true}">Bob</a>
  2223. * ```
  2224. *
  2225. * You can assign the RouterLinkActive instance to a template variable and directly check
  2226. * the `isActive` status.
  2227. * ```
  2228. * <a routerLink="/user/bob" routerLinkActive #rla="routerLinkActive">
  2229. * Bob {{ rla.isActive ? '(already open)' : ''}}
  2230. * </a>
  2231. * ```
  2232. *
  2233. * Finally, you can apply the RouterLinkActive directive to an ancestor of a RouterLink.
  2234. *
  2235. * ```
  2236. * <div routerLinkActive="active-link" [routerLinkActiveOptions]="{exact: true}">
  2237. * <a routerLink="/user/jim">Jim</a>
  2238. * <a routerLink="/user/bob">Bob</a>
  2239. * </div>
  2240. * ```
  2241. *
  2242. * This will set the active-link class on the div tag if the url is either '/user/jim' or
  2243. * '/user/bob'.
  2244. *
  2245. * @ngModule RouterModule
  2246. *
  2247. * @publicApi
  2248. */
  2249. export declare class RouterLinkActive implements OnChanges, OnDestroy, AfterContentInit {
  2250. private router;
  2251. private element;
  2252. private renderer;
  2253. private link?;
  2254. private linkWithHref?;
  2255. links: QueryList<RouterLink>;
  2256. linksWithHrefs: QueryList<RouterLinkWithHref>;
  2257. private classes;
  2258. private subscription;
  2259. readonly isActive: boolean;
  2260. routerLinkActiveOptions: {
  2261. exact: boolean;
  2262. };
  2263. constructor(router: Router, element: ElementRef, renderer: Renderer2, link?: RouterLink | undefined, linkWithHref?: RouterLinkWithHref | undefined);
  2264. ngAfterContentInit(): void;
  2265. routerLinkActive: string[] | string;
  2266. ngOnChanges(changes: SimpleChanges): void;
  2267. ngOnDestroy(): void;
  2268. private update;
  2269. private isLinkActive;
  2270. private hasActiveLinks;
  2271. }
  2272. /**
  2273. * @description
  2274. *
  2275. * Lets you link to specific routes in your app.
  2276. *
  2277. * See `RouterLink` for more information.
  2278. *
  2279. * @ngModule RouterModule
  2280. *
  2281. * @publicApi
  2282. */
  2283. export declare class RouterLinkWithHref implements OnChanges, OnDestroy {
  2284. private router;
  2285. private route;
  2286. private locationStrategy;
  2287. target: string;
  2288. queryParams: {
  2289. [k: string]: any;
  2290. };
  2291. fragment: string;
  2292. queryParamsHandling: QueryParamsHandling;
  2293. preserveFragment: boolean;
  2294. skipLocationChange: boolean;
  2295. replaceUrl: boolean;
  2296. state?: {
  2297. [k: string]: any;
  2298. };
  2299. private commands;
  2300. private subscription;
  2301. private preserve;
  2302. href: string;
  2303. constructor(router: Router, route: ActivatedRoute, locationStrategy: LocationStrategy);
  2304. routerLink: any[] | string;
  2305. preserveQueryParams: boolean;
  2306. ngOnChanges(changes: {}): any;
  2307. ngOnDestroy(): any;
  2308. onClick(button: number, ctrlKey: boolean, metaKey: boolean, shiftKey: boolean): boolean;
  2309. private updateTargetUrlAndHref;
  2310. readonly urlTree: UrlTree;
  2311. }
  2312. /**
  2313. * @usageNotes
  2314. *
  2315. * RouterModule can be imported multiple times: once per lazily-loaded bundle.
  2316. * Since the router deals with a global shared resource--location, we cannot have
  2317. * more than one router service active.
  2318. *
  2319. * That is why there are two ways to create the module: `RouterModule.forRoot` and
  2320. * `RouterModule.forChild`.
  2321. *
  2322. * * `forRoot` creates a module that contains all the directives, the given routes, and the router
  2323. * service itself.
  2324. * * `forChild` creates a module that contains all the directives and the given routes, but does not
  2325. * include the router service.
  2326. *
  2327. * When registered at the root, the module should be used as follows
  2328. *
  2329. * ```
  2330. * @NgModule({
  2331. * imports: [RouterModule.forRoot(ROUTES)]
  2332. * })
  2333. * class MyNgModule {}
  2334. * ```
  2335. *
  2336. * For submodules and lazy loaded submodules the module should be used as follows:
  2337. *
  2338. * ```
  2339. * @NgModule({
  2340. * imports: [RouterModule.forChild(ROUTES)]
  2341. * })
  2342. * class MyNgModule {}
  2343. * ```
  2344. *
  2345. * @description
  2346. *
  2347. * Adds router directives and providers.
  2348. *
  2349. * Managing state transitions is one of the hardest parts of building applications. This is
  2350. * especially true on the web, where you also need to ensure that the state is reflected in the URL.
  2351. * In addition, we often want to split applications into multiple bundles and load them on demand.
  2352. * Doing this transparently is not trivial.
  2353. *
  2354. * The Angular router solves these problems. Using the router, you can declaratively specify
  2355. * application states, manage state transitions while taking care of the URL, and load bundles on
  2356. * demand.
  2357. *
  2358. * [Read this developer guide](https://angular.io/docs/ts/latest/guide/router.html) to get an
  2359. * overview of how the router should be used.
  2360. *
  2361. * @publicApi
  2362. */
  2363. export declare class RouterModule {
  2364. constructor(guard: any, router: Router);
  2365. /**
  2366. * Creates a module with all the router providers and directives. It also optionally sets up an
  2367. * application listener to perform an initial navigation.
  2368. *
  2369. * Configuration Options:
  2370. *
  2371. * * `enableTracing` Toggles whether the router should log all navigation events to the console.
  2372. * * `useHash` Enables the location strategy that uses the URL fragment instead of the history
  2373. * API.
  2374. * * `initialNavigation` Disables the initial navigation.
  2375. * * `errorHandler` Defines a custom error handler for failed navigations.
  2376. * * `preloadingStrategy` Configures a preloading strategy. See `PreloadAllModules`.
  2377. * * `onSameUrlNavigation` Define what the router should do if it receives a navigation request to
  2378. * the current URL.
  2379. * * `scrollPositionRestoration` Configures if the scroll position needs to be restored when
  2380. * navigating back.
  2381. * * `anchorScrolling` Configures if the router should scroll to the element when the url has a
  2382. * fragment.
  2383. * * `scrollOffset` Configures the scroll offset the router will use when scrolling to an element.
  2384. * * `paramsInheritanceStrategy` Defines how the router merges params, data and resolved data from
  2385. * parent to child routes.
  2386. * * `malformedUriErrorHandler` Defines a custom malformed uri error handler function. This
  2387. * handler is invoked when encodedURI contains invalid character sequences.
  2388. * * `urlUpdateStrategy` Defines when the router updates the browser URL. The default behavior is
  2389. * to update after successful navigation.
  2390. * * `relativeLinkResolution` Enables the correct relative link resolution in components with
  2391. * empty paths.
  2392. *
  2393. * See `ExtraOptions` for more details about the above options.
  2394. */
  2395. static forRoot(routes: Routes, config?: ExtraOptions): ModuleWithProviders<RouterModule>;
  2396. /**
  2397. * Creates a module with all the router directives and a provider registering routes.
  2398. */
  2399. static forChild(routes: Routes): ModuleWithProviders<RouterModule>;
  2400. }
  2401. /**
  2402. * @description
  2403. *
  2404. * Acts as a placeholder that Angular dynamically fills based on the current router state.
  2405. *
  2406. * ```
  2407. * <router-outlet></router-outlet>
  2408. * <router-outlet name='left'></router-outlet>
  2409. * <router-outlet name='right'></router-outlet>
  2410. * ```
  2411. *
  2412. * A router outlet will emit an activate event any time a new component is being instantiated,
  2413. * and a deactivate event when it is being destroyed.
  2414. *
  2415. * ```
  2416. * <router-outlet
  2417. * (activate)='onActivate($event)'
  2418. * (deactivate)='onDeactivate($event)'></router-outlet>
  2419. * ```
  2420. * @ngModule RouterModule
  2421. *
  2422. * @publicApi
  2423. */
  2424. export declare class RouterOutlet implements OnDestroy, OnInit {
  2425. private parentContexts;
  2426. private location;
  2427. private resolver;
  2428. private changeDetector;
  2429. private activated;
  2430. private _activatedRoute;
  2431. private name;
  2432. activateEvents: EventEmitter<any>;
  2433. deactivateEvents: EventEmitter<any>;
  2434. constructor(parentContexts: ChildrenOutletContexts, location: ViewContainerRef, resolver: ComponentFactoryResolver, name: string, changeDetector: ChangeDetectorRef);
  2435. ngOnDestroy(): void;
  2436. ngOnInit(): void;
  2437. readonly isActivated: boolean;
  2438. readonly component: Object;
  2439. readonly activatedRoute: ActivatedRoute;
  2440. readonly activatedRouteData: Data;
  2441. /**
  2442. * Called when the `RouteReuseStrategy` instructs to detach the subtree
  2443. */
  2444. detach(): ComponentRef<any>;
  2445. /**
  2446. * Called when the `RouteReuseStrategy` instructs to re-attach a previously detached subtree
  2447. */
  2448. attach(ref: ComponentRef<any>, activatedRoute: ActivatedRoute): void;
  2449. deactivate(): void;
  2450. activateWith(activatedRoute: ActivatedRoute, resolver: ComponentFactoryResolver | null): void;
  2451. }
  2452. /**
  2453. * The preloader optimistically loads all router configurations to
  2454. * make navigations into lazily-loaded sections of the application faster.
  2455. *
  2456. * The preloader runs in the background. When the router bootstraps, the preloader
  2457. * starts listening to all navigation events. After every such event, the preloader
  2458. * will check if any configurations can be loaded lazily.
  2459. *
  2460. * If a route is protected by `canLoad` guards, the preloaded will not load it.
  2461. *
  2462. * @publicApi
  2463. */
  2464. export declare class RouterPreloader implements OnDestroy {
  2465. private router;
  2466. private injector;
  2467. private preloadingStrategy;
  2468. private loader;
  2469. private subscription;
  2470. constructor(router: Router, moduleLoader: NgModuleFactoryLoader, compiler: Compiler, injector: Injector, preloadingStrategy: PreloadingStrategy);
  2471. setUpPreloading(): void;
  2472. preload(): Observable<any>;
  2473. ngOnDestroy(): void;
  2474. private processRoutes;
  2475. private preloadConfig;
  2476. }
  2477. /**
  2478. * @description
  2479. *
  2480. * Represents the state of the router.
  2481. *
  2482. * RouterState is a tree of activated routes. Every node in this tree knows about the "consumed" URL
  2483. * segments, the extracted parameters, and the resolved data.
  2484. *
  2485. * @usageNotes
  2486. * ### Example
  2487. *
  2488. * ```
  2489. * @Component({templateUrl:'template.html'})
  2490. * class MyComponent {
  2491. * constructor(router: Router) {
  2492. * const state: RouterState = router.routerState;
  2493. * const root: ActivatedRoute = state.root;
  2494. * const child = root.firstChild;
  2495. * const id: Observable<string> = child.params.map(p => p.id);
  2496. * //...
  2497. * }
  2498. * }
  2499. * ```
  2500. *
  2501. * See `ActivatedRoute` for more information.
  2502. *
  2503. * @publicApi
  2504. */
  2505. export declare class RouterState extends ɵangular_packages_router_router_m<ActivatedRoute> {
  2506. /** The current snapshot of the router state */
  2507. snapshot: RouterStateSnapshot;
  2508. toString(): string;
  2509. }
  2510. /**
  2511. * @description
  2512. *
  2513. * Represents the state of the router at a moment in time.
  2514. *
  2515. * This is a tree of activated route snapshots. Every node in this tree knows about
  2516. * the "consumed" URL segments, the extracted parameters, and the resolved data.
  2517. *
  2518. * @usageNotes
  2519. * ### Example
  2520. *
  2521. * ```
  2522. * @Component({templateUrl:'template.html'})
  2523. * class MyComponent {
  2524. * constructor(router: Router) {
  2525. * const state: RouterState = router.routerState;
  2526. * const snapshot: RouterStateSnapshot = state.snapshot;
  2527. * const root: ActivatedRouteSnapshot = snapshot.root;
  2528. * const child = root.firstChild;
  2529. * const id: Observable<string> = child.params.map(p => p.id);
  2530. * //...
  2531. * }
  2532. * }
  2533. * ```
  2534. *
  2535. * @publicApi
  2536. */
  2537. export declare class RouterStateSnapshot extends ɵangular_packages_router_router_m<ActivatedRouteSnapshot> {
  2538. /** The url from which this snapshot was created */
  2539. url: string;
  2540. toString(): string;
  2541. }
  2542. /**
  2543. * @docsNotRequired
  2544. * @publicApi
  2545. */
  2546. export declare const ROUTES: InjectionToken<Route[][]>;
  2547. /**
  2548. * Represents a route configuration for the Router service.
  2549. * An array of `Route` objects, used in `Router.config` and for nested route configurations
  2550. * in `Route.children`.
  2551. *
  2552. * @see `Route`
  2553. * @see `Router`
  2554. * @publicApi
  2555. */
  2556. export declare type Routes = Route[];
  2557. /**
  2558. * @description
  2559. *
  2560. * Represents an event triggered when routes are recognized.
  2561. *
  2562. * @publicApi
  2563. */
  2564. export declare class RoutesRecognized extends RouterEvent {
  2565. /** @docsNotRequired */
  2566. urlAfterRedirects: string;
  2567. /** @docsNotRequired */
  2568. state: RouterStateSnapshot;
  2569. constructor(
  2570. /** @docsNotRequired */
  2571. id: number,
  2572. /** @docsNotRequired */
  2573. url: string,
  2574. /** @docsNotRequired */
  2575. urlAfterRedirects: string,
  2576. /** @docsNotRequired */
  2577. state: RouterStateSnapshot);
  2578. /** @docsNotRequired */
  2579. toString(): string;
  2580. }
  2581. /**
  2582. *
  2583. * A policy for when to run guards and resolvers on a route.
  2584. *
  2585. * @see `Route#runGuardsAndResolvers`
  2586. * @publicApi
  2587. */
  2588. export declare type RunGuardsAndResolvers = 'pathParamsChange' | 'pathParamsOrQueryParamsChange' | 'paramsChange' | 'paramsOrQueryParamsChange' | 'always' | ((from: ActivatedRouteSnapshot, to: ActivatedRouteSnapshot) => boolean);
  2589. /**
  2590. * @description
  2591. *
  2592. * Represents a scrolling event.
  2593. *
  2594. * @publicApi
  2595. */
  2596. export declare class Scroll {
  2597. /** @docsNotRequired */
  2598. readonly routerEvent: NavigationEnd;
  2599. /** @docsNotRequired */
  2600. readonly position: [number, number] | null;
  2601. /** @docsNotRequired */
  2602. readonly anchor: string | null;
  2603. constructor(
  2604. /** @docsNotRequired */
  2605. routerEvent: NavigationEnd,
  2606. /** @docsNotRequired */
  2607. position: [number, number] | null,
  2608. /** @docsNotRequired */
  2609. anchor: string | null);
  2610. toString(): string;
  2611. }
  2612. /**
  2613. * @description
  2614. *
  2615. * Provides a way to migrate AngularJS applications to Angular.
  2616. *
  2617. * @publicApi
  2618. */
  2619. export declare abstract class UrlHandlingStrategy {
  2620. /**
  2621. * Tells the router if this URL should be processed.
  2622. *
  2623. * When it returns true, the router will execute the regular navigation.
  2624. * When it returns false, the router will set the router state to an empty state.
  2625. * As a result, all the active components will be destroyed.
  2626. *
  2627. */
  2628. abstract shouldProcessUrl(url: UrlTree): boolean;
  2629. /**
  2630. * Extracts the part of the URL that should be handled by the router.
  2631. * The rest of the URL will remain untouched.
  2632. */
  2633. abstract extract(url: UrlTree): UrlTree;
  2634. /**
  2635. * Merges the URL fragment with the rest of the URL.
  2636. */
  2637. abstract merge(newUrlPart: UrlTree, rawUrl: UrlTree): UrlTree;
  2638. }
  2639. /**
  2640. * A function for matching a route against URLs. Implement a custom URL matcher
  2641. * for `Route.matcher` when a combination of `path` and `pathMatch`
  2642. * is not expressive enough.
  2643. *
  2644. * @param segments An array of URL segments.
  2645. * @param group A segment group.
  2646. * @param route The route to match against.
  2647. * @returns The match-result,
  2648. *
  2649. * @usageNotes
  2650. *
  2651. * The following matcher matches HTML files.
  2652. *
  2653. * ```
  2654. * export function htmlFiles(url: UrlSegment[]) {
  2655. * return url.length === 1 && url[0].path.endsWith('.html') ? ({consumed: url}) : null;
  2656. * }
  2657. *
  2658. * export const routes = [{ matcher: htmlFiles, component: AnyComponent }];
  2659. * ```
  2660. *
  2661. * @publicApi
  2662. */
  2663. export declare type UrlMatcher = (segments: UrlSegment[], group: UrlSegmentGroup, route: Route) => UrlMatchResult;
  2664. /**
  2665. * Represents the result of matching URLs with a custom matching function.
  2666. *
  2667. * * `consumed` is an array of the consumed URL segments.
  2668. * * `posParams` is a map of positional parameters.
  2669. *
  2670. * @see `UrlMatcher()`
  2671. * @publicApi
  2672. */
  2673. export declare type UrlMatchResult = {
  2674. consumed: UrlSegment[];
  2675. posParams?: {
  2676. [name: string]: UrlSegment;
  2677. };
  2678. };
  2679. /**
  2680. * @description
  2681. *
  2682. * Represents a single URL segment.
  2683. *
  2684. * A UrlSegment is a part of a URL between the two slashes. It contains a path and the matrix
  2685. * parameters associated with the segment.
  2686. *
  2687. * @usageNotes
  2688. * ### Example
  2689. *
  2690. * ```
  2691. * @Component({templateUrl:'template.html'})
  2692. * class MyComponent {
  2693. * constructor(router: Router) {
  2694. * const tree: UrlTree = router.parseUrl('/team;id=33');
  2695. * const g: UrlSegmentGroup = tree.root.children[PRIMARY_OUTLET];
  2696. * const s: UrlSegment[] = g.segments;
  2697. * s[0].path; // returns 'team'
  2698. * s[0].parameters; // returns {id: 33}
  2699. * }
  2700. * }
  2701. * ```
  2702. *
  2703. * @publicApi
  2704. */
  2705. export declare class UrlSegment {
  2706. /** The path part of a URL segment */
  2707. path: string;
  2708. /** The matrix parameters associated with a segment */
  2709. parameters: {
  2710. [name: string]: string;
  2711. };
  2712. constructor(
  2713. /** The path part of a URL segment */
  2714. path: string,
  2715. /** The matrix parameters associated with a segment */
  2716. parameters: {
  2717. [name: string]: string;
  2718. });
  2719. readonly parameterMap: ParamMap;
  2720. /** @docsNotRequired */
  2721. toString(): string;
  2722. }
  2723. /**
  2724. * @description
  2725. *
  2726. * Represents the parsed URL segment group.
  2727. *
  2728. * See `UrlTree` for more information.
  2729. *
  2730. * @publicApi
  2731. */
  2732. export declare class UrlSegmentGroup {
  2733. /** The URL segments of this group. See `UrlSegment` for more information */
  2734. segments: UrlSegment[];
  2735. /** The list of children of this group */
  2736. children: {
  2737. [key: string]: UrlSegmentGroup;
  2738. };
  2739. /** The parent node in the url tree */
  2740. parent: UrlSegmentGroup | null;
  2741. constructor(
  2742. /** The URL segments of this group. See `UrlSegment` for more information */
  2743. segments: UrlSegment[],
  2744. /** The list of children of this group */
  2745. children: {
  2746. [key: string]: UrlSegmentGroup;
  2747. });
  2748. /** Whether the segment has child segments */
  2749. hasChildren(): boolean;
  2750. /** Number of child segments */
  2751. readonly numberOfChildren: number;
  2752. /** @docsNotRequired */
  2753. toString(): string;
  2754. }
  2755. /**
  2756. * @description
  2757. *
  2758. * Serializes and deserializes a URL string into a URL tree.
  2759. *
  2760. * The url serialization strategy is customizable. You can
  2761. * make all URLs case insensitive by providing a custom UrlSerializer.
  2762. *
  2763. * See `DefaultUrlSerializer` for an example of a URL serializer.
  2764. *
  2765. * @publicApi
  2766. */
  2767. export declare abstract class UrlSerializer {
  2768. /** Parse a url into a `UrlTree` */
  2769. abstract parse(url: string): UrlTree;
  2770. /** Converts a `UrlTree` into a url */
  2771. abstract serialize(tree: UrlTree): string;
  2772. }
  2773. /**
  2774. * @description
  2775. *
  2776. * Represents the parsed URL.
  2777. *
  2778. * Since a router state is a tree, and the URL is nothing but a serialized state, the URL is a
  2779. * serialized tree.
  2780. * UrlTree is a data structure that provides a lot of affordances in dealing with URLs
  2781. *
  2782. * @usageNotes
  2783. * ### Example
  2784. *
  2785. * ```
  2786. * @Component({templateUrl:'template.html'})
  2787. * class MyComponent {
  2788. * constructor(router: Router) {
  2789. * const tree: UrlTree =
  2790. * router.parseUrl('/team/33/(user/victor//support:help)?debug=true#fragment');
  2791. * const f = tree.fragment; // return 'fragment'
  2792. * const q = tree.queryParams; // returns {debug: 'true'}
  2793. * const g: UrlSegmentGroup = tree.root.children[PRIMARY_OUTLET];
  2794. * const s: UrlSegment[] = g.segments; // returns 2 segments 'team' and '33'
  2795. * g.children[PRIMARY_OUTLET].segments; // returns 2 segments 'user' and 'victor'
  2796. * g.children['support'].segments; // return 1 segment 'help'
  2797. * }
  2798. * }
  2799. * ```
  2800. *
  2801. * @publicApi
  2802. */
  2803. export declare class UrlTree {
  2804. /** The root segment group of the URL tree */
  2805. root: UrlSegmentGroup;
  2806. /** The query params of the URL */
  2807. queryParams: Params;
  2808. /** The fragment of the URL */
  2809. fragment: string | null;
  2810. readonly queryParamMap: ParamMap;
  2811. /** @docsNotRequired */
  2812. toString(): string;
  2813. }
  2814. /**
  2815. * @publicApi
  2816. */
  2817. export declare const VERSION: Version;
  2818. /**
  2819. * @docsNotRequired
  2820. */
  2821. export declare const ɵangular_packages_router_router_a: InjectionToken<void>;
  2822. export declare function ɵangular_packages_router_router_b(): NgProbeToken;
  2823. export declare function ɵangular_packages_router_router_c(router: Router, viewportScroller: ViewportScroller, config: ExtraOptions): ɵangular_packages_router_router_o;
  2824. export declare function ɵangular_packages_router_router_d(platformLocationStrategy: PlatformLocation, baseHref: string, options?: ExtraOptions): HashLocationStrategy | PathLocationStrategy;
  2825. export declare function ɵangular_packages_router_router_e(router: Router): any;
  2826. export declare function ɵangular_packages_router_router_f(ref: ApplicationRef, urlSerializer: UrlSerializer, contexts: ChildrenOutletContexts, location: Location, injector: Injector, loader: NgModuleFactoryLoader, compiler: Compiler, config: Route[][], opts?: ExtraOptions, urlHandlingStrategy?: UrlHandlingStrategy, routeReuseStrategy?: RouteReuseStrategy): Router;
  2827. export declare function ɵangular_packages_router_router_g(router: Router): ActivatedRoute;
  2828. /**
  2829. * To initialize the router properly we need to do in two steps:
  2830. *
  2831. * We need to start the navigation in a APP_INITIALIZER to block the bootstrap if
  2832. * a resolver or a guards executes asynchronously. Second, we need to actually run
  2833. * activation in a BOOTSTRAP_LISTENER. We utilize the afterPreactivation
  2834. * hook provided by the router to do that.
  2835. *
  2836. * The router navigation starts, reaches the point when preactivation is done, and then
  2837. * pauses. It waits for the hook to be resolved. We then resolve it only in a bootstrap listener.
  2838. */
  2839. export declare class ɵangular_packages_router_router_h {
  2840. private injector;
  2841. private initNavigation;
  2842. private resultOfPreactivationDone;
  2843. constructor(injector: Injector);
  2844. appInitializer(): Promise<any>;
  2845. bootstrapListener(bootstrappedComponentRef: ComponentRef<any>): void;
  2846. private isLegacyEnabled;
  2847. private isLegacyDisabled;
  2848. }
  2849. export declare function ɵangular_packages_router_router_i(r: ɵangular_packages_router_router_h): any;
  2850. export declare function ɵangular_packages_router_router_j(r: ɵangular_packages_router_router_h): any;
  2851. export declare function ɵangular_packages_router_router_k(): (typeof ɵangular_packages_router_router_h | {
  2852. provide: InjectionToken<(() => void)[]>;
  2853. multi: boolean;
  2854. useFactory: typeof ɵangular_packages_router_router_i;
  2855. deps: (typeof ɵangular_packages_router_router_h)[];
  2856. useExisting?: undefined;
  2857. } | {
  2858. provide: InjectionToken<(compRef: ComponentRef<any>) => void>;
  2859. useFactory: typeof ɵangular_packages_router_router_j;
  2860. deps: (typeof ɵangular_packages_router_router_h)[];
  2861. multi?: undefined;
  2862. useExisting?: undefined;
  2863. } | {
  2864. provide: InjectionToken<((compRef: ComponentRef<any>) => void)[]>;
  2865. multi: boolean;
  2866. useExisting: InjectionToken<(compRef: ComponentRef<any>) => void>;
  2867. useFactory?: undefined;
  2868. deps?: undefined;
  2869. })[];
  2870. export declare class ɵangular_packages_router_router_m<T> {
  2871. constructor(root: ɵangular_packages_router_router_n<T>);
  2872. readonly root: T;
  2873. }
  2874. export declare class ɵangular_packages_router_router_n<T> {
  2875. value: T;
  2876. children: ɵangular_packages_router_router_n<T>[];
  2877. constructor(value: T, children: ɵangular_packages_router_router_n<T>[]);
  2878. toString(): string;
  2879. }
  2880. export declare class ɵangular_packages_router_router_o implements OnDestroy {
  2881. private router;
  2882. /** @docsNotRequired */ readonly viewportScroller: ViewportScroller;
  2883. private options;
  2884. private routerEventsSubscription;
  2885. private scrollEventsSubscription;
  2886. private lastId;
  2887. private lastSource;
  2888. private restoredId;
  2889. private store;
  2890. constructor(router: Router,
  2891. /** @docsNotRequired */ viewportScroller: ViewportScroller, options?: {
  2892. scrollPositionRestoration?: 'disabled' | 'enabled' | 'top';
  2893. anchorScrolling?: 'disabled' | 'enabled';
  2894. });
  2895. init(): void;
  2896. private createScrollEvents;
  2897. private consumeScrollEvents;
  2898. private scheduleScrollEvent;
  2899. ngOnDestroy(): void;
  2900. }
  2901. /**
  2902. * This component is used internally within the router to be a placeholder when an empty
  2903. * router-outlet is needed. For example, with a config such as:
  2904. *
  2905. * `{path: 'parent', outlet: 'nav', children: [...]}`
  2906. *
  2907. * In order to render, there needs to be a component on this config, which will default
  2908. * to this `EmptyOutletComponent`.
  2909. */
  2910. declare class ɵEmptyOutletComponent {
  2911. }
  2912. export { ɵEmptyOutletComponent }
  2913. export { ɵEmptyOutletComponent as ɵangular_packages_router_router_l }
  2914. /**
  2915. * Flattens single-level nested arrays.
  2916. */
  2917. export declare function ɵflatten<T>(arr: T[][]): T[];
  2918. export declare const ɵROUTER_PROVIDERS: Provider[];
  2919. export { }