index.d.ts 160 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693
  1. /**
  2. * @license Angular v16.0.4
  3. * (c) 2010-2022 Google LLC. https://angular.io/
  4. * License: MIT
  5. */
  6. import { AfterContentInit } from '@angular/core';
  7. import { ChangeDetectorRef } from '@angular/core';
  8. import { Compiler } from '@angular/core';
  9. import { ComponentRef } from '@angular/core';
  10. import { ElementRef } from '@angular/core';
  11. import { EnvironmentInjector } from '@angular/core';
  12. import { EnvironmentProviders } from '@angular/core';
  13. import { EventEmitter } from '@angular/core';
  14. import * as i0 from '@angular/core';
  15. import { InjectionToken } from '@angular/core';
  16. import { Injector } from '@angular/core';
  17. import { LocationStrategy } from '@angular/common';
  18. import { ModuleWithProviders } from '@angular/core';
  19. import { NgModuleFactory } from '@angular/core';
  20. import { Observable } from 'rxjs';
  21. import { OnChanges } from '@angular/core';
  22. import { OnDestroy } from '@angular/core';
  23. import { OnInit } from '@angular/core';
  24. import { Provider } from '@angular/core';
  25. import { ProviderToken } from '@angular/core';
  26. import { QueryList } from '@angular/core';
  27. import { Renderer2 } from '@angular/core';
  28. import { SimpleChanges } from '@angular/core';
  29. import { Title } from '@angular/platform-browser';
  30. import { Type } from '@angular/core';
  31. import { Version } from '@angular/core';
  32. /**
  33. * Provides access to information about a route associated with a component
  34. * that is loaded in an outlet.
  35. * Use to traverse the `RouterState` tree and extract information from nodes.
  36. *
  37. * The following example shows how to construct a component using information from a
  38. * currently activated route.
  39. *
  40. * Note: the observables in this class only emit when the current and previous values differ based
  41. * on shallow equality. For example, changing deeply nested properties in resolved `data` will not
  42. * cause the `ActivatedRoute.data` `Observable` to emit a new value.
  43. *
  44. * {@example router/activated-route/module.ts region="activated-route"
  45. * header="activated-route.component.ts"}
  46. *
  47. * @see [Getting route information](guide/router#getting-route-information)
  48. *
  49. * @publicApi
  50. */
  51. export declare class ActivatedRoute {
  52. /** The outlet name of the route, a constant. */
  53. outlet: string;
  54. /** The component of the route, a constant. */
  55. component: Type<any> | null;
  56. /** The current snapshot of this route */
  57. snapshot: ActivatedRouteSnapshot;
  58. /** An Observable of the resolved route title */
  59. readonly title: Observable<string | undefined>;
  60. /** An observable of the URL segments matched by this route. */
  61. url: Observable<UrlSegment[]>;
  62. /** An observable of the matrix parameters scoped to this route. */
  63. params: Observable<Params>;
  64. /** An observable of the query parameters shared by all the routes. */
  65. queryParams: Observable<Params>;
  66. /** An observable of the URL fragment shared by all the routes. */
  67. fragment: Observable<string | null>;
  68. /** An observable of the static and resolved data of this route. */
  69. data: Observable<Data>;
  70. /** The configuration used to match this route. */
  71. get routeConfig(): Route | null;
  72. /** The root of the router state. */
  73. get root(): ActivatedRoute;
  74. /** The parent of this route in the router state tree. */
  75. get parent(): ActivatedRoute | null;
  76. /** The first child of this route in the router state tree. */
  77. get firstChild(): ActivatedRoute | null;
  78. /** The children of this route in the router state tree. */
  79. get children(): ActivatedRoute[];
  80. /** The path from the root of the router state tree to this route. */
  81. get pathFromRoot(): ActivatedRoute[];
  82. /**
  83. * An Observable that contains a map of the required and optional parameters
  84. * specific to the route.
  85. * The map supports retrieving single and multiple values from the same parameter.
  86. */
  87. get paramMap(): Observable<ParamMap>;
  88. /**
  89. * An Observable that contains a map of the query parameters available to all routes.
  90. * The map supports retrieving single and multiple values from the query parameter.
  91. */
  92. get queryParamMap(): Observable<ParamMap>;
  93. toString(): string;
  94. }
  95. /**
  96. * @description
  97. *
  98. * Contains the information about a route associated with a component loaded in an
  99. * outlet at a particular moment in time. ActivatedRouteSnapshot can also be used to
  100. * traverse the router state tree.
  101. *
  102. * The following example initializes a component with route information extracted
  103. * from the snapshot of the root node at the time of creation.
  104. *
  105. * ```
  106. * @Component({templateUrl:'./my-component.html'})
  107. * class MyComponent {
  108. * constructor(route: ActivatedRoute) {
  109. * const id: string = route.snapshot.params.id;
  110. * const url: string = route.snapshot.url.join('');
  111. * const user = route.snapshot.data.user;
  112. * }
  113. * }
  114. * ```
  115. *
  116. * @publicApi
  117. */
  118. export declare class ActivatedRouteSnapshot {
  119. /** The URL segments matched by this route */
  120. url: UrlSegment[];
  121. /**
  122. * The matrix parameters scoped to this route.
  123. *
  124. * You can compute all params (or data) in the router state or to get params outside
  125. * of an activated component by traversing the `RouterState` tree as in the following
  126. * example:
  127. * ```
  128. * collectRouteParams(router: Router) {
  129. * let params = {};
  130. * let stack: ActivatedRouteSnapshot[] = [router.routerState.snapshot.root];
  131. * while (stack.length > 0) {
  132. * const route = stack.pop()!;
  133. * params = {...params, ...route.params};
  134. * stack.push(...route.children);
  135. * }
  136. * return params;
  137. * }
  138. * ```
  139. */
  140. params: Params;
  141. /** The query parameters shared by all the routes */
  142. queryParams: Params;
  143. /** The URL fragment shared by all the routes */
  144. fragment: string | null;
  145. /** The static and resolved data of this route */
  146. data: Data;
  147. /** The outlet name of the route */
  148. outlet: string;
  149. /** The component of the route */
  150. component: Type<any> | null;
  151. /** The configuration used to match this route **/
  152. readonly routeConfig: Route | null;
  153. /** The resolved route title */
  154. get title(): string | undefined;
  155. /** The root of the router state */
  156. get root(): ActivatedRouteSnapshot;
  157. /** The parent of this route in the router state tree */
  158. get parent(): ActivatedRouteSnapshot | null;
  159. /** The first child of this route in the router state tree */
  160. get firstChild(): ActivatedRouteSnapshot | null;
  161. /** The children of this route in the router state tree */
  162. get children(): ActivatedRouteSnapshot[];
  163. /** The path from the root of the router state tree to this route */
  164. get pathFromRoot(): ActivatedRouteSnapshot[];
  165. get paramMap(): ParamMap;
  166. get queryParamMap(): ParamMap;
  167. toString(): string;
  168. }
  169. /**
  170. * An event triggered at the end of the activation part
  171. * of the Resolve phase of routing.
  172. * @see `ActivationStart`
  173. * @see `ResolveStart`
  174. *
  175. * @publicApi
  176. */
  177. export declare class ActivationEnd {
  178. /** @docsNotRequired */
  179. snapshot: ActivatedRouteSnapshot;
  180. readonly type = EventType.ActivationEnd;
  181. constructor(
  182. /** @docsNotRequired */
  183. snapshot: ActivatedRouteSnapshot);
  184. toString(): string;
  185. }
  186. /**
  187. * An event triggered at the start of the activation part
  188. * of the Resolve phase of routing.
  189. * @see `ActivationEnd`
  190. * @see `ResolveStart`
  191. *
  192. * @publicApi
  193. */
  194. export declare class ActivationStart {
  195. /** @docsNotRequired */
  196. snapshot: ActivatedRouteSnapshot;
  197. readonly type = EventType.ActivationStart;
  198. constructor(
  199. /** @docsNotRequired */
  200. snapshot: ActivatedRouteSnapshot);
  201. toString(): string;
  202. }
  203. /**
  204. * @description
  205. *
  206. * This base route reuse strategy only reuses routes when the matched router configs are
  207. * identical. This prevents components from being destroyed and recreated
  208. * when just the route parameters, query parameters or fragment change
  209. * (that is, the existing component is _reused_).
  210. *
  211. * This strategy does not store any routes for later reuse.
  212. *
  213. * Angular uses this strategy by default.
  214. *
  215. *
  216. * It can be used as a base class for custom route reuse strategies, i.e. you can create your own
  217. * class that extends the `BaseRouteReuseStrategy` one.
  218. * @publicApi
  219. */
  220. export declare abstract class BaseRouteReuseStrategy implements RouteReuseStrategy {
  221. /**
  222. * Whether the given route should detach for later reuse.
  223. * Always returns false for `BaseRouteReuseStrategy`.
  224. * */
  225. shouldDetach(route: ActivatedRouteSnapshot): boolean;
  226. /**
  227. * A no-op; the route is never stored since this strategy never detaches routes for later re-use.
  228. */
  229. store(route: ActivatedRouteSnapshot, detachedTree: DetachedRouteHandle): void;
  230. /** Returns `false`, meaning the route (and its subtree) is never reattached */
  231. shouldAttach(route: ActivatedRouteSnapshot): boolean;
  232. /** Returns `null` because this strategy does not store routes for later re-use. */
  233. retrieve(route: ActivatedRouteSnapshot): DetachedRouteHandle | null;
  234. /**
  235. * Determines if a route should be reused.
  236. * This strategy returns `true` when the future route config and current route config are
  237. * identical.
  238. */
  239. shouldReuseRoute(future: ActivatedRouteSnapshot, curr: ActivatedRouteSnapshot): boolean;
  240. }
  241. /**
  242. * @description
  243. *
  244. * Interface that a class can implement to be a guard deciding if a route can be activated.
  245. * If all guards return `true`, navigation continues. If any guard returns `false`,
  246. * navigation is cancelled. If any guard returns a `UrlTree`, the current navigation
  247. * is cancelled and a new navigation begins to the `UrlTree` returned from the guard.
  248. *
  249. * The following example implements a `CanActivate` function that checks whether the
  250. * current user has permission to activate the requested route.
  251. *
  252. * ```
  253. * class UserToken {}
  254. * class Permissions {
  255. * canActivate(): boolean {
  256. * return true;
  257. * }
  258. * }
  259. *
  260. * @Injectable()
  261. * class CanActivateTeam implements CanActivate {
  262. * constructor(private permissions: Permissions, private currentUser: UserToken) {}
  263. *
  264. * canActivate(
  265. * route: ActivatedRouteSnapshot,
  266. * state: RouterStateSnapshot
  267. * ): Observable<boolean|UrlTree>|Promise<boolean|UrlTree>|boolean|UrlTree {
  268. * return this.permissions.canActivate(this.currentUser, route.params.id);
  269. * }
  270. * }
  271. * ```
  272. *
  273. * Here, the defined guard function is provided as part of the `Route` object
  274. * in the router configuration:
  275. *
  276. * ```
  277. * @NgModule({
  278. * imports: [
  279. * RouterModule.forRoot([
  280. * {
  281. * path: 'team/:id',
  282. * component: TeamComponent,
  283. * canActivate: [CanActivateTeam]
  284. * }
  285. * ])
  286. * ],
  287. * providers: [CanActivateTeam, UserToken, Permissions]
  288. * })
  289. * class AppModule {}
  290. * ```
  291. *
  292. * @publicApi
  293. * @deprecated Class-based `Route` guards are deprecated in favor of functional guards. An
  294. * injectable class can be used as a functional guard using the `inject` function:
  295. * `canActivate: [() => inject(myGuard).canActivate()]`.
  296. * @see `CanActivateFn`
  297. */
  298. export declare interface CanActivate {
  299. canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree;
  300. }
  301. /**
  302. * @description
  303. *
  304. * Interface that a class can implement to be a guard deciding if a child route can be activated.
  305. * If all guards return `true`, navigation continues. If any guard returns `false`,
  306. * navigation is cancelled. If any guard returns a `UrlTree`, current navigation
  307. * is cancelled and a new navigation begins to the `UrlTree` returned from the guard.
  308. *
  309. * The following example implements a `CanActivateChild` function that checks whether the
  310. * current user has permission to activate the requested child route.
  311. *
  312. * ```
  313. * class UserToken {}
  314. * class Permissions {
  315. * canActivate(user: UserToken, id: string): boolean {
  316. * return true;
  317. * }
  318. * }
  319. *
  320. * @Injectable()
  321. * class CanActivateTeam implements CanActivateChild {
  322. * constructor(private permissions: Permissions, private currentUser: UserToken) {}
  323. *
  324. * canActivateChild(
  325. * route: ActivatedRouteSnapshot,
  326. * state: RouterStateSnapshot
  327. * ): Observable<boolean|UrlTree>|Promise<boolean|UrlTree>|boolean|UrlTree {
  328. * return this.permissions.canActivate(this.currentUser, route.params.id);
  329. * }
  330. * }
  331. * ```
  332. *
  333. * Here, the defined guard function is provided as part of the `Route` object
  334. * in the router configuration:
  335. *
  336. * ```
  337. * @NgModule({
  338. * imports: [
  339. * RouterModule.forRoot([
  340. * {
  341. * path: 'root',
  342. * canActivateChild: [CanActivateTeam],
  343. * children: [
  344. * {
  345. * path: 'team/:id',
  346. * component: TeamComponent
  347. * }
  348. * ]
  349. * }
  350. * ])
  351. * ],
  352. * providers: [CanActivateTeam, UserToken, Permissions]
  353. * })
  354. * class AppModule {}
  355. * ```
  356. *
  357. * @publicApi
  358. * @deprecated Class-based `Route` guards are deprecated in favor of functional guards. An
  359. * injectable class can be used as a functional guard using the `inject` function:
  360. * `canActivateChild: [() => inject(myGuard).canActivateChild()]`.
  361. * @see `CanActivateChildFn`
  362. */
  363. export declare interface CanActivateChild {
  364. canActivateChild(childRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree;
  365. }
  366. /**
  367. * The signature of a function used as a `canActivateChild` guard on a `Route`.
  368. *
  369. * If all guards return `true`, navigation continues. If any guard returns `false`,
  370. * navigation is cancelled. If any guard returns a `UrlTree`, the current navigation
  371. * is cancelled and a new navigation begins to the `UrlTree` returned from the guard.
  372. *
  373. * The following example implements a `canActivate` function that checks whether the
  374. * current user has permission to activate the requested route.
  375. *
  376. * {@example router/route_functional_guards.ts region="CanActivateChildFn"}
  377. *
  378. * @publicApi
  379. * @see `Route`
  380. */
  381. export declare type CanActivateChildFn = (childRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot) => Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree;
  382. /**
  383. * The signature of a function used as a `canActivate` guard on a `Route`.
  384. *
  385. * If all guards return `true`, navigation continues. If any guard returns `false`,
  386. * navigation is cancelled. If any guard returns a `UrlTree`, the current navigation
  387. * is cancelled and a new navigation begins to the `UrlTree` returned from the guard.
  388. *
  389. * The following example implements and uses a `CanActivateChildFn` that checks whether the
  390. * current user has permission to activate the requested route.
  391. *
  392. * {@example router/route_functional_guards.ts region="CanActivateFn"}
  393. * Here, the defined guard function is provided as part of the `Route` object
  394. * in the router configuration:
  395. * {@example router/route_functional_guards.ts region="CanActivateFnInRoute"}
  396. *
  397. * @publicApi
  398. * @see `Route`
  399. */
  400. export declare type CanActivateFn = (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) => Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree;
  401. /**
  402. * @description
  403. *
  404. * Interface that a class can implement to be a guard deciding if a route can be deactivated.
  405. * If all guards return `true`, navigation continues. If any guard returns `false`,
  406. * navigation is cancelled. If any guard returns a `UrlTree`, current navigation
  407. * is cancelled and a new navigation begins to the `UrlTree` returned from the guard.
  408. *
  409. * The following example implements a `CanDeactivate` function that checks whether the
  410. * current user has permission to deactivate the requested route.
  411. *
  412. * ```
  413. * class UserToken {}
  414. * class Permissions {
  415. * canDeactivate(user: UserToken, id: string): boolean {
  416. * return true;
  417. * }
  418. * }
  419. * ```
  420. *
  421. * Here, the defined guard function is provided as part of the `Route` object
  422. * in the router configuration:
  423. *
  424. * ```
  425. *
  426. * @Injectable()
  427. * class CanDeactivateTeam implements CanDeactivate<TeamComponent> {
  428. * constructor(private permissions: Permissions, private currentUser: UserToken) {}
  429. *
  430. * canDeactivate(
  431. * component: TeamComponent,
  432. * currentRoute: ActivatedRouteSnapshot,
  433. * currentState: RouterStateSnapshot,
  434. * nextState: RouterStateSnapshot
  435. * ): Observable<boolean|UrlTree>|Promise<boolean|UrlTree>|boolean|UrlTree {
  436. * return this.permissions.canDeactivate(this.currentUser, route.params.id);
  437. * }
  438. * }
  439. *
  440. * @NgModule({
  441. * imports: [
  442. * RouterModule.forRoot([
  443. * {
  444. * path: 'team/:id',
  445. * component: TeamComponent,
  446. * canDeactivate: [CanDeactivateTeam]
  447. * }
  448. * ])
  449. * ],
  450. * providers: [CanDeactivateTeam, UserToken, Permissions]
  451. * })
  452. * class AppModule {}
  453. * ```
  454. *
  455. * @publicApi
  456. * @deprecated Class-based `Route` guards are deprecated in favor of functional guards. An
  457. * injectable class can be used as a functional guard using the `inject` function:
  458. * `canDeactivate: [() => inject(myGuard).canDeactivate()]`.
  459. * @see `CanDeactivateFn`
  460. */
  461. export declare interface CanDeactivate<T> {
  462. canDeactivate(component: T, currentRoute: ActivatedRouteSnapshot, currentState: RouterStateSnapshot, nextState: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree;
  463. }
  464. /**
  465. * The signature of a function used as a `canDeactivate` guard on a `Route`.
  466. *
  467. * If all guards return `true`, navigation continues. If any guard returns `false`,
  468. * navigation is cancelled. If any guard returns a `UrlTree`, the current navigation
  469. * is cancelled and a new navigation begins to the `UrlTree` returned from the guard.
  470. *
  471. * The following example implements and uses a `CanDeactivateFn` that checks whether the
  472. * user component has unsaved changes before navigating away from the route.
  473. *
  474. * {@example router/route_functional_guards.ts region="CanDeactivateFn"}
  475. *
  476. * @publicApi
  477. * @see `Route`
  478. */
  479. export declare type CanDeactivateFn<T> = (component: T, currentRoute: ActivatedRouteSnapshot, currentState: RouterStateSnapshot, nextState: RouterStateSnapshot) => Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree;
  480. /**
  481. * @description
  482. *
  483. * Interface that a class can implement to be a guard deciding if children can be loaded.
  484. * If all guards return `true`, navigation continues. If any guard returns `false`,
  485. * navigation is cancelled. If any guard returns a `UrlTree`, current navigation
  486. * is cancelled and a new navigation starts to the `UrlTree` returned from the guard.
  487. *
  488. * The following example implements a `CanLoad` function that decides whether the
  489. * current user has permission to load requested child routes.
  490. *
  491. *
  492. * ```
  493. * class UserToken {}
  494. * class Permissions {
  495. * canLoadChildren(user: UserToken, id: string, segments: UrlSegment[]): boolean {
  496. * return true;
  497. * }
  498. * }
  499. *
  500. * @Injectable()
  501. * class CanLoadTeamSection implements CanLoad {
  502. * constructor(private permissions: Permissions, private currentUser: UserToken) {}
  503. *
  504. * canLoad(route: Route, segments: UrlSegment[]): Observable<boolean>|Promise<boolean>|boolean {
  505. * return this.permissions.canLoadChildren(this.currentUser, route, segments);
  506. * }
  507. * }
  508. * ```
  509. *
  510. * Here, the defined guard function is provided as part of the `Route` object
  511. * in the router configuration:
  512. *
  513. * ```
  514. *
  515. * @NgModule({
  516. * imports: [
  517. * RouterModule.forRoot([
  518. * {
  519. * path: 'team/:id',
  520. * component: TeamComponent,
  521. * loadChildren: () => import('./team').then(mod => mod.TeamModule),
  522. * canLoad: [CanLoadTeamSection]
  523. * }
  524. * ])
  525. * ],
  526. * providers: [CanLoadTeamSection, UserToken, Permissions]
  527. * })
  528. * class AppModule {}
  529. * ```
  530. *
  531. * @publicApi
  532. * @deprecated Use {@link CanMatchFn} instead
  533. */
  534. export declare interface CanLoad {
  535. canLoad(route: Route, segments: UrlSegment[]): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree;
  536. }
  537. /**
  538. * The signature of a function used as a `canLoad` guard on a `Route`.
  539. *
  540. * @publicApi
  541. * @see `CanLoad`
  542. * @see `Route`
  543. * @see `CanMatchFn`
  544. * @deprecated Use `Route.canMatch` and `CanMatchFn` instead
  545. */
  546. export declare type CanLoadFn = (route: Route, segments: UrlSegment[]) => Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree;
  547. /**
  548. * @description
  549. *
  550. * Interface that a class can implement to be a guard deciding if a `Route` can be matched.
  551. * If all guards return `true`, navigation continues and the `Router` will use the `Route` during
  552. * activation. If any guard returns `false`, the `Route` is skipped for matching and other `Route`
  553. * configurations are processed instead.
  554. *
  555. * The following example implements a `CanMatch` function that decides whether the
  556. * current user has permission to access the users page.
  557. *
  558. *
  559. * ```
  560. * class UserToken {}
  561. * class Permissions {
  562. * canAccess(user: UserToken, route: Route, segments: UrlSegment[]): boolean {
  563. * return true;
  564. * }
  565. * }
  566. *
  567. * @Injectable()
  568. * class CanMatchTeamSection implements CanMatch {
  569. * constructor(private permissions: Permissions, private currentUser: UserToken) {}
  570. *
  571. * canMatch(route: Route, segments: UrlSegment[]): Observable<boolean>|Promise<boolean>|boolean {
  572. * return this.permissions.canAccess(this.currentUser, route, segments);
  573. * }
  574. * }
  575. * ```
  576. *
  577. * Here, the defined guard function is provided as part of the `Route` object
  578. * in the router configuration:
  579. *
  580. * ```
  581. *
  582. * @NgModule({
  583. * imports: [
  584. * RouterModule.forRoot([
  585. * {
  586. * path: 'team/:id',
  587. * component: TeamComponent,
  588. * loadChildren: () => import('./team').then(mod => mod.TeamModule),
  589. * canMatch: [CanMatchTeamSection]
  590. * },
  591. * {
  592. * path: '**',
  593. * component: NotFoundComponent
  594. * }
  595. * ])
  596. * ],
  597. * providers: [CanMatchTeamSection, UserToken, Permissions]
  598. * })
  599. * class AppModule {}
  600. * ```
  601. *
  602. * If the `CanMatchTeamSection` were to return `false`, the router would continue navigating to the
  603. * `team/:id` URL, but would load the `NotFoundComponent` because the `Route` for `'team/:id'`
  604. * could not be used for a URL match but the catch-all `**` `Route` did instead.
  605. *
  606. * @publicApi
  607. * @deprecated Class-based `Route` guards are deprecated in favor of functional guards. An
  608. * injectable class can be used as a functional guard using the `inject` function:
  609. * `canMatch: [() => inject(myGuard).canMatch()]`.
  610. * @see `CanMatchFn`
  611. */
  612. export declare interface CanMatch {
  613. canMatch(route: Route, segments: UrlSegment[]): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree;
  614. }
  615. /**
  616. * The signature of a function used as a `canMatch` guard on a `Route`.
  617. *
  618. * If all guards return `true`, navigation continues and the `Router` will use the `Route` during
  619. * activation. If any guard returns `false`, the `Route` is skipped for matching and other `Route`
  620. * configurations are processed instead.
  621. *
  622. * The following example implements and uses a `CanMatchFn` that checks whether the
  623. * current user has permission to access the team page.
  624. *
  625. * {@example router/route_functional_guards.ts region="CanMatchFn"}
  626. *
  627. * @publicApi
  628. * @see `Route`
  629. */
  630. export declare type CanMatchFn = (route: Route, segments: UrlSegment[]) => Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree;
  631. /**
  632. * An event triggered at the end of the child-activation part
  633. * of the Resolve phase of routing.
  634. * @see `ChildActivationStart`
  635. * @see `ResolveStart`
  636. * @publicApi
  637. */
  638. export declare class ChildActivationEnd {
  639. /** @docsNotRequired */
  640. snapshot: ActivatedRouteSnapshot;
  641. readonly type = EventType.ChildActivationEnd;
  642. constructor(
  643. /** @docsNotRequired */
  644. snapshot: ActivatedRouteSnapshot);
  645. toString(): string;
  646. }
  647. /**
  648. * An event triggered at the start of the child-activation
  649. * part of the Resolve phase of routing.
  650. * @see `ChildActivationEnd`
  651. * @see `ResolveStart`
  652. *
  653. * @publicApi
  654. */
  655. export declare class ChildActivationStart {
  656. /** @docsNotRequired */
  657. snapshot: ActivatedRouteSnapshot;
  658. readonly type = EventType.ChildActivationStart;
  659. constructor(
  660. /** @docsNotRequired */
  661. snapshot: ActivatedRouteSnapshot);
  662. toString(): string;
  663. }
  664. /**
  665. * Store contextual information about the children (= nested) `RouterOutlet`
  666. *
  667. * @publicApi
  668. */
  669. export declare class ChildrenOutletContexts {
  670. private contexts;
  671. /** Called when a `RouterOutlet` directive is instantiated */
  672. onChildOutletCreated(childName: string, outlet: RouterOutletContract): void;
  673. /**
  674. * Called when a `RouterOutlet` directive is destroyed.
  675. * We need to keep the context as the outlet could be destroyed inside a NgIf and might be
  676. * re-created later.
  677. */
  678. onChildOutletDestroyed(childName: string): void;
  679. /**
  680. * Called when the corresponding route is deactivated during navigation.
  681. * Because the component get destroyed, all children outlet are destroyed.
  682. */
  683. onOutletDeactivated(): Map<string, OutletContext>;
  684. onOutletReAttached(contexts: Map<string, OutletContext>): void;
  685. getOrCreateContext(childName: string): OutletContext;
  686. getContext(childName: string): OutletContext | null;
  687. static ɵfac: i0.ɵɵFactoryDeclaration<ChildrenOutletContexts, never>;
  688. static ɵprov: i0.ɵɵInjectableDeclaration<ChildrenOutletContexts>;
  689. }
  690. /**
  691. * A type alias for providers returned by `withComponentInputBinding` for use with `provideRouter`.
  692. *
  693. * @see `withComponentInputBinding`
  694. * @see `provideRouter`
  695. *
  696. * @publicApi
  697. */
  698. declare type ComponentInputBindingFeature = RouterFeature<RouterFeatureKind.ComponentInputBindingFeature>;
  699. /**
  700. * Converts a `Params` instance to a `ParamMap`.
  701. * @param params The instance to convert.
  702. * @returns The new map instance.
  703. *
  704. * @publicApi
  705. */
  706. export declare function convertToParamMap(params: Params): ParamMap;
  707. /**
  708. * Creates a `UrlTree` relative to an `ActivatedRouteSnapshot`.
  709. *
  710. * @publicApi
  711. *
  712. *
  713. * @param relativeTo The `ActivatedRouteSnapshot` to apply the commands to
  714. * @param commands An array of URL fragments with which to construct the new URL tree.
  715. * If the path is static, can be the literal URL string. For a dynamic path, pass an array of path
  716. * segments, followed by the parameters for each segment.
  717. * The fragments are applied to the one provided in the `relativeTo` parameter.
  718. * @param queryParams The query parameters for the `UrlTree`. `null` if the `UrlTree` does not have
  719. * any query parameters.
  720. * @param fragment The fragment for the `UrlTree`. `null` if the `UrlTree` does not have a fragment.
  721. *
  722. * @usageNotes
  723. *
  724. * ```
  725. * // create /team/33/user/11
  726. * createUrlTreeFromSnapshot(snapshot, ['/team', 33, 'user', 11]);
  727. *
  728. * // create /team/33;expand=true/user/11
  729. * createUrlTreeFromSnapshot(snapshot, ['/team', 33, {expand: true}, 'user', 11]);
  730. *
  731. * // you can collapse static segments like this (this works only with the first passed-in value):
  732. * createUrlTreeFromSnapshot(snapshot, ['/team/33/user', userId]);
  733. *
  734. * // If the first segment can contain slashes, and you do not want the router to split it,
  735. * // you can do the following:
  736. * createUrlTreeFromSnapshot(snapshot, [{segmentPath: '/one/two'}]);
  737. *
  738. * // create /team/33/(user/11//right:chat)
  739. * createUrlTreeFromSnapshot(snapshot, ['/team', 33, {outlets: {primary: 'user/11', right:
  740. * 'chat'}}], null, null);
  741. *
  742. * // remove the right secondary node
  743. * createUrlTreeFromSnapshot(snapshot, ['/team', 33, {outlets: {primary: 'user/11', right: null}}]);
  744. *
  745. * // For the examples below, assume the current URL is for the `/team/33/user/11` and the
  746. * `ActivatedRouteSnapshot` points to `user/11`:
  747. *
  748. * // navigate to /team/33/user/11/details
  749. * createUrlTreeFromSnapshot(snapshot, ['details']);
  750. *
  751. * // navigate to /team/33/user/22
  752. * createUrlTreeFromSnapshot(snapshot, ['../22']);
  753. *
  754. * // navigate to /team/44/user/22
  755. * createUrlTreeFromSnapshot(snapshot, ['../../team/44/user/22']);
  756. * ```
  757. */
  758. export declare function createUrlTreeFromSnapshot(relativeTo: ActivatedRouteSnapshot, commands: any[], queryParams?: Params | null, fragment?: string | null): UrlTree;
  759. /**
  760. *
  761. * Represents static data associated with a particular route.
  762. *
  763. * @see `Route#data`
  764. *
  765. * @publicApi
  766. */
  767. export declare type Data = {
  768. [key: string | symbol]: any;
  769. };
  770. /**
  771. * A type alias for providers returned by `withDebugTracing` for use with `provideRouter`.
  772. *
  773. * @see `withDebugTracing`
  774. * @see `provideRouter`
  775. *
  776. * @publicApi
  777. */
  778. export declare type DebugTracingFeature = RouterFeature<RouterFeatureKind.DebugTracingFeature>;
  779. /**
  780. * An ES Module object with a default export of the given type.
  781. *
  782. * @see `Route#loadComponent`
  783. * @see `LoadChildrenCallback`
  784. *
  785. * @publicApi
  786. */
  787. export declare interface DefaultExport<T> {
  788. /**
  789. * Default exports are bound under the name `"default"`, per the ES Module spec:
  790. * https://tc39.es/ecma262/#table-export-forms-mapping-to-exportentry-records
  791. */
  792. default: T;
  793. }
  794. /**
  795. * The default `TitleStrategy` used by the router that updates the title using the `Title` service.
  796. */
  797. export declare class DefaultTitleStrategy extends TitleStrategy {
  798. readonly title: Title;
  799. constructor(title: Title);
  800. /**
  801. * Sets the title of the browser to the given value.
  802. *
  803. * @param title The `pageTitle` from the deepest primary route.
  804. */
  805. updateTitle(snapshot: RouterStateSnapshot): void;
  806. static ɵfac: i0.ɵɵFactoryDeclaration<DefaultTitleStrategy, never>;
  807. static ɵprov: i0.ɵɵInjectableDeclaration<DefaultTitleStrategy>;
  808. }
  809. /**
  810. * Matches the route configuration (`route`) against the actual URL (`segments`).
  811. *
  812. * When no matcher is defined on a `Route`, this is the matcher used by the Router by default.
  813. *
  814. * @param segments The remaining unmatched segments in the current navigation
  815. * @param segmentGroup The current segment group being matched
  816. * @param route The `Route` to match against.
  817. *
  818. * @see UrlMatchResult
  819. * @see Route
  820. *
  821. * @returns The resulting match information or `null` if the `route` should not match.
  822. * @publicApi
  823. */
  824. export declare function defaultUrlMatcher(segments: UrlSegment[], segmentGroup: UrlSegmentGroup, route: Route): UrlMatchResult | null;
  825. /**
  826. * @description
  827. *
  828. * A default implementation of the `UrlSerializer`.
  829. *
  830. * Example URLs:
  831. *
  832. * ```
  833. * /inbox/33(popup:compose)
  834. * /inbox/33;open=true/messages/44
  835. * ```
  836. *
  837. * DefaultUrlSerializer uses parentheses to serialize secondary segments (e.g., popup:compose), the
  838. * colon syntax to specify the outlet, and the ';parameter=value' syntax (e.g., open=true) to
  839. * specify route specific parameters.
  840. *
  841. * @publicApi
  842. */
  843. export declare class DefaultUrlSerializer implements UrlSerializer {
  844. /** Parses a url into a `UrlTree` */
  845. parse(url: string): UrlTree;
  846. /** Converts a `UrlTree` into a url */
  847. serialize(tree: UrlTree): string;
  848. }
  849. /**
  850. * The `InjectionToken` and `@Injectable` classes for guards and resolvers are deprecated in favor
  851. * of plain JavaScript functions instead.. Dependency injection can still be achieved using the
  852. * `inject` function from `@angular/core` and an injectable class can be used as a functional guard
  853. * using `inject`: `canActivate: [() => inject(myGuard).canActivate()]`.
  854. *
  855. * @deprecated
  856. * @see `CanMatchFn`
  857. * @see `CanLoadFn`
  858. * @see `CanActivateFn`
  859. * @see `CanActivateChildFn`
  860. * @see `CanDeactivateFn`
  861. * @see `ResolveFn`
  862. * @see `inject`
  863. * @publicApi
  864. */
  865. export declare type DeprecatedGuard = ProviderToken<any> | any;
  866. /**
  867. * @description
  868. *
  869. * Represents the detached route tree.
  870. *
  871. * This is an opaque value the router will give to a custom route reuse strategy
  872. * to store and retrieve later on.
  873. *
  874. * @publicApi
  875. */
  876. export declare type DetachedRouteHandle = {};
  877. /**
  878. * A type alias for providers returned by `withDisabledInitialNavigation` for use with
  879. * `provideRouter`.
  880. *
  881. * @see `withDisabledInitialNavigation`
  882. * @see `provideRouter`
  883. *
  884. * @publicApi
  885. */
  886. export declare type DisabledInitialNavigationFeature = RouterFeature<RouterFeatureKind.DisabledInitialNavigationFeature>;
  887. /**
  888. * A type alias for providers returned by `withEnabledBlockingInitialNavigation` for use with
  889. * `provideRouter`.
  890. *
  891. * @see `withEnabledBlockingInitialNavigation`
  892. * @see `provideRouter`
  893. *
  894. * @publicApi
  895. */
  896. export declare type EnabledBlockingInitialNavigationFeature = RouterFeature<RouterFeatureKind.EnabledBlockingInitialNavigationFeature>;
  897. /**
  898. * Router events that allow you to track the lifecycle of the router.
  899. *
  900. * The events occur in the following sequence:
  901. *
  902. * * [NavigationStart](api/router/NavigationStart): Navigation starts.
  903. * * [RouteConfigLoadStart](api/router/RouteConfigLoadStart): Before
  904. * the router [lazy loads](/guide/router#lazy-loading) a route configuration.
  905. * * [RouteConfigLoadEnd](api/router/RouteConfigLoadEnd): After a route has been lazy loaded.
  906. * * [RoutesRecognized](api/router/RoutesRecognized): When the router parses the URL
  907. * and the routes are recognized.
  908. * * [GuardsCheckStart](api/router/GuardsCheckStart): When the router begins the *guards*
  909. * phase of routing.
  910. * * [ChildActivationStart](api/router/ChildActivationStart): When the router
  911. * begins activating a route's children.
  912. * * [ActivationStart](api/router/ActivationStart): When the router begins activating a route.
  913. * * [GuardsCheckEnd](api/router/GuardsCheckEnd): When the router finishes the *guards*
  914. * phase of routing successfully.
  915. * * [ResolveStart](api/router/ResolveStart): When the router begins the *resolve*
  916. * phase of routing.
  917. * * [ResolveEnd](api/router/ResolveEnd): When the router finishes the *resolve*
  918. * phase of routing successfully.
  919. * * [ChildActivationEnd](api/router/ChildActivationEnd): When the router finishes
  920. * activating a route's children.
  921. * * [ActivationEnd](api/router/ActivationEnd): When the router finishes activating a route.
  922. * * [NavigationEnd](api/router/NavigationEnd): When navigation ends successfully.
  923. * * [NavigationCancel](api/router/NavigationCancel): When navigation is canceled.
  924. * * [NavigationError](api/router/NavigationError): When navigation fails
  925. * due to an unexpected error.
  926. * * [Scroll](api/router/Scroll): When the user scrolls.
  927. *
  928. * @publicApi
  929. */
  930. declare type Event_2 = NavigationStart | NavigationEnd | NavigationCancel | NavigationError | RoutesRecognized | GuardsCheckStart | GuardsCheckEnd | RouteConfigLoadStart | RouteConfigLoadEnd | ChildActivationStart | ChildActivationEnd | ActivationStart | ActivationEnd | Scroll | ResolveStart | ResolveEnd | NavigationSkipped;
  931. export { Event_2 as Event }
  932. /**
  933. * Identifies the type of a router event.
  934. *
  935. * @publicApi
  936. */
  937. export declare const enum EventType {
  938. NavigationStart = 0,
  939. NavigationEnd = 1,
  940. NavigationCancel = 2,
  941. NavigationError = 3,
  942. RoutesRecognized = 4,
  943. ResolveStart = 5,
  944. ResolveEnd = 6,
  945. GuardsCheckStart = 7,
  946. GuardsCheckEnd = 8,
  947. RouteConfigLoadStart = 9,
  948. RouteConfigLoadEnd = 10,
  949. ChildActivationStart = 11,
  950. ChildActivationEnd = 12,
  951. ActivationStart = 13,
  952. ActivationEnd = 14,
  953. Scroll = 15,
  954. NavigationSkipped = 16
  955. }
  956. /**
  957. * A set of configuration options for a router module, provided in the
  958. * `forRoot()` method.
  959. *
  960. * @see `forRoot()`
  961. *
  962. *
  963. * @publicApi
  964. */
  965. export declare interface ExtraOptions extends InMemoryScrollingOptions, RouterConfigOptions {
  966. /**
  967. * When true, log all internal navigation events to the console.
  968. * Use for debugging.
  969. */
  970. enableTracing?: boolean;
  971. /**
  972. * When true, enable the location strategy that uses the URL fragment
  973. * instead of the history API.
  974. */
  975. useHash?: boolean;
  976. /**
  977. * One of `enabled`, `enabledBlocking`, `enabledNonBlocking` or `disabled`.
  978. * When set to `enabled` or `enabledBlocking`, the initial navigation starts before the root
  979. * component is created. The bootstrap is blocked until the initial navigation is complete. This
  980. * value is required for [server-side rendering](guide/universal) to work. When set to
  981. * `enabledNonBlocking`, the initial navigation starts after the root component has been created.
  982. * The bootstrap is not blocked on the completion of the initial navigation. When set to
  983. * `disabled`, the initial navigation is not performed. The location listener is set up before the
  984. * root component gets created. Use if there is a reason to have more control over when the router
  985. * starts its initial navigation due to some complex initialization logic.
  986. */
  987. initialNavigation?: InitialNavigation;
  988. /**
  989. * When true, enables binding information from the `Router` state directly to the inputs of the
  990. * component in `Route` configurations.
  991. */
  992. bindToComponentInputs?: boolean;
  993. /**
  994. * A custom error handler for failed navigations.
  995. * If the handler returns a value, the navigation Promise is resolved with this value.
  996. * If the handler throws an exception, the navigation Promise is rejected with the exception.
  997. *
  998. * @deprecated Subscribe to the `Router` events and watch for `NavigationError` instead.
  999. */
  1000. errorHandler?: (error: any) => any;
  1001. /**
  1002. * Configures a preloading strategy.
  1003. * One of `PreloadAllModules` or `NoPreloading` (the default).
  1004. */
  1005. preloadingStrategy?: any;
  1006. /**
  1007. * Configures the scroll offset the router will use when scrolling to an element.
  1008. *
  1009. * When given a tuple with x and y position value,
  1010. * the router uses that offset each time it scrolls.
  1011. * When given a function, the router invokes the function every time
  1012. * it restores scroll position.
  1013. */
  1014. scrollOffset?: [number, number] | (() => [number, number]);
  1015. /**
  1016. * A custom handler for malformed URI errors. The handler is invoked when `encodedURI` contains
  1017. * invalid character sequences.
  1018. * The default implementation is to redirect to the root URL, dropping
  1019. * any path or parameter information. The function takes three parameters:
  1020. *
  1021. * - `'URIError'` - Error thrown when parsing a bad URL.
  1022. * - `'UrlSerializer'` - UrlSerializer that’s configured with the router.
  1023. * - `'url'` - The malformed URL that caused the URIError
  1024. *
  1025. * @deprecated URI parsing errors should be handled in the `UrlSerializer` instead.
  1026. * */
  1027. malformedUriErrorHandler?: (error: URIError, urlSerializer: UrlSerializer, url: string) => UrlTree;
  1028. }
  1029. /**
  1030. * An event triggered at the end of the Guard phase of routing.
  1031. *
  1032. * @see `GuardsCheckStart`
  1033. *
  1034. * @publicApi
  1035. */
  1036. export declare class GuardsCheckEnd extends RouterEvent {
  1037. /** @docsNotRequired */
  1038. urlAfterRedirects: string;
  1039. /** @docsNotRequired */
  1040. state: RouterStateSnapshot;
  1041. /** @docsNotRequired */
  1042. shouldActivate: boolean;
  1043. readonly type = EventType.GuardsCheckEnd;
  1044. constructor(
  1045. /** @docsNotRequired */
  1046. id: number,
  1047. /** @docsNotRequired */
  1048. url: string,
  1049. /** @docsNotRequired */
  1050. urlAfterRedirects: string,
  1051. /** @docsNotRequired */
  1052. state: RouterStateSnapshot,
  1053. /** @docsNotRequired */
  1054. shouldActivate: boolean);
  1055. toString(): string;
  1056. }
  1057. /**
  1058. * An event triggered at the start of the Guard phase of routing.
  1059. *
  1060. * @see `GuardsCheckEnd`
  1061. *
  1062. * @publicApi
  1063. */
  1064. export declare class GuardsCheckStart extends RouterEvent {
  1065. /** @docsNotRequired */
  1066. urlAfterRedirects: string;
  1067. /** @docsNotRequired */
  1068. state: RouterStateSnapshot;
  1069. readonly type = EventType.GuardsCheckStart;
  1070. constructor(
  1071. /** @docsNotRequired */
  1072. id: number,
  1073. /** @docsNotRequired */
  1074. url: string,
  1075. /** @docsNotRequired */
  1076. urlAfterRedirects: string,
  1077. /** @docsNotRequired */
  1078. state: RouterStateSnapshot);
  1079. toString(): string;
  1080. }
  1081. declare namespace i1 {
  1082. export {
  1083. RouterOutletContract,
  1084. RouterOutlet,
  1085. INPUT_BINDER,
  1086. RoutedComponentInputBinder
  1087. }
  1088. }
  1089. declare namespace i2 {
  1090. export {
  1091. RouterLink,
  1092. RouterLink as RouterLinkWithHref
  1093. }
  1094. }
  1095. declare namespace i3 {
  1096. export {
  1097. RouterLinkActive
  1098. }
  1099. }
  1100. declare namespace i4 {
  1101. export {
  1102. ɵEmptyOutletComponent,
  1103. ɵEmptyOutletComponent as EmptyOutletComponent
  1104. }
  1105. }
  1106. /**
  1107. * Allowed values in an `ExtraOptions` object that configure
  1108. * when the router performs the initial navigation operation.
  1109. *
  1110. * * 'enabledNonBlocking' - (default) The initial navigation starts after the
  1111. * root component has been created. The bootstrap is not blocked on the completion of the initial
  1112. * navigation.
  1113. * * 'enabledBlocking' - The initial navigation starts before the root component is created.
  1114. * The bootstrap is blocked until the initial navigation is complete. This value is required
  1115. * for [server-side rendering](guide/universal) to work.
  1116. * * 'disabled' - The initial navigation is not performed. The location listener is set up before
  1117. * the root component gets created. Use if there is a reason to have
  1118. * more control over when the router starts its initial navigation due to some complex
  1119. * initialization logic.
  1120. *
  1121. * @see `forRoot()`
  1122. *
  1123. * @publicApi
  1124. */
  1125. export declare type InitialNavigation = 'disabled' | 'enabledBlocking' | 'enabledNonBlocking';
  1126. /**
  1127. * A type alias for providers returned by `withEnabledBlockingInitialNavigation` or
  1128. * `withDisabledInitialNavigation` functions for use with `provideRouter`.
  1129. *
  1130. * @see `withEnabledBlockingInitialNavigation`
  1131. * @see `withDisabledInitialNavigation`
  1132. * @see `provideRouter`
  1133. *
  1134. * @publicApi
  1135. */
  1136. export declare type InitialNavigationFeature = EnabledBlockingInitialNavigationFeature | DisabledInitialNavigationFeature;
  1137. /**
  1138. * A type alias for providers returned by `withInMemoryScrolling` for use with `provideRouter`.
  1139. *
  1140. * @see `withInMemoryScrolling`
  1141. * @see `provideRouter`
  1142. *
  1143. * @publicApi
  1144. */
  1145. export declare type InMemoryScrollingFeature = RouterFeature<RouterFeatureKind.InMemoryScrollingFeature>;
  1146. /**
  1147. * Configuration options for the scrolling feature which can be used with `withInMemoryScrolling`
  1148. * function.
  1149. *
  1150. * @publicApi
  1151. */
  1152. export declare interface InMemoryScrollingOptions {
  1153. /**
  1154. * When set to 'enabled', scrolls to the anchor element when the URL has a fragment.
  1155. * Anchor scrolling is disabled by default.
  1156. *
  1157. * Anchor scrolling does not happen on 'popstate'. Instead, we restore the position
  1158. * that we stored or scroll to the top.
  1159. */
  1160. anchorScrolling?: 'disabled' | 'enabled';
  1161. /**
  1162. * Configures if the scroll position needs to be restored when navigating back.
  1163. *
  1164. * * 'disabled'- (Default) Does nothing. Scroll position is maintained on navigation.
  1165. * * 'top'- Sets the scroll position to x = 0, y = 0 on all navigation.
  1166. * * 'enabled'- Restores the previous scroll position on backward navigation, else sets the
  1167. * position to the anchor if one is provided, or sets the scroll position to [0, 0] (forward
  1168. * navigation). This option will be the default in the future.
  1169. *
  1170. * You can implement custom scroll restoration behavior by adapting the enabled behavior as
  1171. * in the following example.
  1172. *
  1173. * ```typescript
  1174. * class AppComponent {
  1175. * movieData: any;
  1176. *
  1177. * constructor(private router: Router, private viewportScroller: ViewportScroller,
  1178. * changeDetectorRef: ChangeDetectorRef) {
  1179. * router.events.pipe(filter((event: Event): event is Scroll => event instanceof Scroll)
  1180. * ).subscribe(e => {
  1181. * fetch('http://example.com/movies.json').then(response => {
  1182. * this.movieData = response.json();
  1183. * // update the template with the data before restoring scroll
  1184. * changeDetectorRef.detectChanges();
  1185. *
  1186. * if (e.position) {
  1187. * viewportScroller.scrollToPosition(e.position);
  1188. * }
  1189. * });
  1190. * });
  1191. * }
  1192. * }
  1193. * ```
  1194. */
  1195. scrollPositionRestoration?: 'disabled' | 'enabled' | 'top';
  1196. }
  1197. declare const INPUT_BINDER: InjectionToken<RoutedComponentInputBinder>;
  1198. /**
  1199. * A set of options which specify how to determine if a `UrlTree` is active, given the `UrlTree`
  1200. * for the current router state.
  1201. *
  1202. * @publicApi
  1203. * @see Router.isActive
  1204. */
  1205. export declare interface IsActiveMatchOptions {
  1206. /**
  1207. * Defines the strategy for comparing the matrix parameters of two `UrlTree`s.
  1208. *
  1209. * The matrix parameter matching is dependent on the strategy for matching the
  1210. * segments. That is, if the `paths` option is set to `'subset'`, only
  1211. * the matrix parameters of the matching segments will be compared.
  1212. *
  1213. * - `'exact'`: Requires that matching segments also have exact matrix parameter
  1214. * matches.
  1215. * - `'subset'`: The matching segments in the router's active `UrlTree` may contain
  1216. * extra matrix parameters, but those that exist in the `UrlTree` in question must match.
  1217. * - `'ignored'`: When comparing `UrlTree`s, matrix params will be ignored.
  1218. */
  1219. matrixParams: 'exact' | 'subset' | 'ignored';
  1220. /**
  1221. * Defines the strategy for comparing the query parameters of two `UrlTree`s.
  1222. *
  1223. * - `'exact'`: the query parameters must match exactly.
  1224. * - `'subset'`: the active `UrlTree` may contain extra parameters,
  1225. * but must match the key and value of any that exist in the `UrlTree` in question.
  1226. * - `'ignored'`: When comparing `UrlTree`s, query params will be ignored.
  1227. */
  1228. queryParams: 'exact' | 'subset' | 'ignored';
  1229. /**
  1230. * Defines the strategy for comparing the `UrlSegment`s of the `UrlTree`s.
  1231. *
  1232. * - `'exact'`: all segments in each `UrlTree` must match.
  1233. * - `'subset'`: a `UrlTree` will be determined to be active if it
  1234. * is a subtree of the active route. That is, the active route may contain extra
  1235. * segments, but must at least have all the segments of the `UrlTree` in question.
  1236. */
  1237. paths: 'exact' | 'subset';
  1238. /**
  1239. * - `'exact'`: indicates that the `UrlTree` fragments must be equal.
  1240. * - `'ignored'`: the fragments will not be compared when determining if a
  1241. * `UrlTree` is active.
  1242. */
  1243. fragment: 'exact' | 'ignored';
  1244. }
  1245. /**
  1246. *
  1247. * A function that returns a set of routes to load.
  1248. *
  1249. * @see `LoadChildrenCallback`
  1250. * @publicApi
  1251. */
  1252. export declare type LoadChildren = LoadChildrenCallback;
  1253. /**
  1254. *
  1255. * A function that is called to resolve a collection of lazy-loaded routes.
  1256. * Must be an arrow function of the following form:
  1257. * `() => import('...').then(mod => mod.MODULE)`
  1258. * or
  1259. * `() => import('...').then(mod => mod.ROUTES)`
  1260. *
  1261. * For example:
  1262. *
  1263. * ```
  1264. * [{
  1265. * path: 'lazy',
  1266. * loadChildren: () => import('./lazy-route/lazy.module').then(mod => mod.LazyModule),
  1267. * }];
  1268. * ```
  1269. * or
  1270. * ```
  1271. * [{
  1272. * path: 'lazy',
  1273. * loadChildren: () => import('./lazy-route/lazy.routes').then(mod => mod.ROUTES),
  1274. * }];
  1275. * ```
  1276. *
  1277. * If the lazy-loaded routes are exported via a `default` export, the `.then` can be omitted:
  1278. * ```
  1279. * [{
  1280. * path: 'lazy',
  1281. * loadChildren: () => import('./lazy-route/lazy.routes'),
  1282. * }];
  1283. * ```
  1284. *
  1285. * @see [Route.loadChildren](api/router/Route#loadChildren)
  1286. * @publicApi
  1287. */
  1288. export declare type LoadChildrenCallback = () => Type<any> | NgModuleFactory<any> | Routes | Observable<Type<any> | Routes | DefaultExport<Type<any>> | DefaultExport<Routes>> | Promise<NgModuleFactory<any> | Type<any> | Routes | DefaultExport<Type<any>> | DefaultExport<Routes>>;
  1289. declare interface LoadedRouterConfig {
  1290. routes: Route[];
  1291. injector: EnvironmentInjector | undefined;
  1292. }
  1293. /**
  1294. * Maps an array of injectable classes with canActivate functions to an array of equivalent
  1295. * `CanActivateFn` for use in a `Route` definition.
  1296. *
  1297. * Usage {@example router/utils/functional_guards.ts region='CanActivate'}
  1298. *
  1299. * @publicApi
  1300. * @see Route
  1301. */
  1302. export declare function mapToCanActivate(providers: Array<Type<{
  1303. canActivate: CanActivateFn;
  1304. }>>): CanActivateFn[];
  1305. /**
  1306. * Maps an array of injectable classes with canActivateChild functions to an array of equivalent
  1307. * `CanActivateChildFn` for use in a `Route` definition.
  1308. *
  1309. * Usage {@example router/utils/functional_guards.ts region='CanActivate'}
  1310. *
  1311. * @publicApi
  1312. * @see Route
  1313. */
  1314. export declare function mapToCanActivateChild(providers: Array<Type<{
  1315. canActivateChild: CanActivateChildFn;
  1316. }>>): CanActivateChildFn[];
  1317. /**
  1318. * Maps an array of injectable classes with canDeactivate functions to an array of equivalent
  1319. * `CanDeactivateFn` for use in a `Route` definition.
  1320. *
  1321. * Usage {@example router/utils/functional_guards.ts region='CanActivate'}
  1322. *
  1323. * @publicApi
  1324. * @see Route
  1325. */
  1326. export declare function mapToCanDeactivate<T = unknown>(providers: Array<Type<{
  1327. canDeactivate: CanDeactivateFn<T>;
  1328. }>>): CanDeactivateFn<T>[];
  1329. /**
  1330. * Maps an array of injectable classes with canMatch functions to an array of equivalent
  1331. * `CanMatchFn` for use in a `Route` definition.
  1332. *
  1333. * Usage {@example router/utils/functional_guards.ts region='CanActivate'}
  1334. *
  1335. * @publicApi
  1336. * @see Route
  1337. */
  1338. export declare function mapToCanMatch(providers: Array<Type<{
  1339. canMatch: CanMatchFn;
  1340. }>>): CanMatchFn[];
  1341. /**
  1342. * Maps an injectable class with a resolve function to an equivalent `ResolveFn`
  1343. * for use in a `Route` definition.
  1344. *
  1345. * Usage {@example router/utils/functional_guards.ts region='Resolve'}
  1346. *
  1347. * @publicApi
  1348. * @see Route
  1349. */
  1350. export declare function mapToResolve<T>(provider: Type<{
  1351. resolve: ResolveFn<T>;
  1352. }>): ResolveFn<T>;
  1353. /**
  1354. * Information about a navigation operation.
  1355. * Retrieve the most recent navigation object with the
  1356. * [Router.getCurrentNavigation() method](api/router/Router#getcurrentnavigation) .
  1357. *
  1358. * * *id* : The unique identifier of the current navigation.
  1359. * * *initialUrl* : The target URL passed into the `Router#navigateByUrl()` call before navigation.
  1360. * This is the value before the router has parsed or applied redirects to it.
  1361. * * *extractedUrl* : The initial target URL after being parsed with `UrlSerializer.extract()`.
  1362. * * *finalUrl* : The extracted URL after redirects have been applied.
  1363. * This URL may not be available immediately, therefore this property can be `undefined`.
  1364. * It is guaranteed to be set after the `RoutesRecognized` event fires.
  1365. * * *trigger* : Identifies how this navigation was triggered.
  1366. * -- 'imperative'--Triggered by `router.navigateByUrl` or `router.navigate`.
  1367. * -- 'popstate'--Triggered by a popstate event.
  1368. * -- 'hashchange'--Triggered by a hashchange event.
  1369. * * *extras* : A `NavigationExtras` options object that controlled the strategy used for this
  1370. * navigation.
  1371. * * *previousNavigation* : The previously successful `Navigation` object. Only one previous
  1372. * navigation is available, therefore this previous `Navigation` object has a `null` value for its
  1373. * own `previousNavigation`.
  1374. *
  1375. * @publicApi
  1376. */
  1377. export declare interface Navigation {
  1378. /**
  1379. * The unique identifier of the current navigation.
  1380. */
  1381. id: number;
  1382. /**
  1383. * The target URL passed into the `Router#navigateByUrl()` call before navigation. This is
  1384. * the value before the router has parsed or applied redirects to it.
  1385. */
  1386. initialUrl: UrlTree;
  1387. /**
  1388. * The initial target URL after being parsed with `UrlHandlingStrategy.extract()`.
  1389. */
  1390. extractedUrl: UrlTree;
  1391. /**
  1392. * The extracted URL after redirects have been applied.
  1393. * This URL may not be available immediately, therefore this property can be `undefined`.
  1394. * It is guaranteed to be set after the `RoutesRecognized` event fires.
  1395. */
  1396. finalUrl?: UrlTree;
  1397. /**
  1398. * Identifies how this navigation was triggered.
  1399. *
  1400. * * 'imperative'--Triggered by `router.navigateByUrl` or `router.navigate`.
  1401. * * 'popstate'--Triggered by a popstate event.
  1402. * * 'hashchange'--Triggered by a hashchange event.
  1403. */
  1404. trigger: 'imperative' | 'popstate' | 'hashchange';
  1405. /**
  1406. * Options that controlled the strategy used for this navigation.
  1407. * See `NavigationExtras`.
  1408. */
  1409. extras: NavigationExtras;
  1410. /**
  1411. * The previously successful `Navigation` object. Only one previous navigation
  1412. * is available, therefore this previous `Navigation` object has a `null` value
  1413. * for its own `previousNavigation`.
  1414. */
  1415. previousNavigation: Navigation | null;
  1416. }
  1417. /**
  1418. * @description
  1419. *
  1420. * Options that modify the `Router` navigation strategy.
  1421. * Supply an object containing any of these properties to a `Router` navigation function to
  1422. * control how the navigation should be handled.
  1423. *
  1424. * @see [Router.navigate() method](api/router/Router#navigate)
  1425. * @see [Router.navigateByUrl() method](api/router/Router#navigatebyurl)
  1426. * @see [Routing and Navigation guide](guide/router)
  1427. *
  1428. * @publicApi
  1429. */
  1430. export declare interface NavigationBehaviorOptions {
  1431. /**
  1432. * How to handle a navigation request to the current URL.
  1433. *
  1434. * This value is a subset of the options available in `OnSameUrlNavigation` and
  1435. * will take precedence over the default value set for the `Router`.
  1436. *
  1437. * @see `OnSameUrlNavigation`
  1438. * @see `RouterConfigOptions`
  1439. */
  1440. onSameUrlNavigation?: Extract<OnSameUrlNavigation, 'reload'>;
  1441. /**
  1442. * When true, navigates without pushing a new state into history.
  1443. *
  1444. * ```
  1445. * // Navigate silently to /view
  1446. * this.router.navigate(['/view'], { skipLocationChange: true });
  1447. * ```
  1448. */
  1449. skipLocationChange?: boolean;
  1450. /**
  1451. * When true, navigates while replacing the current state in history.
  1452. *
  1453. * ```
  1454. * // Navigate to /view
  1455. * this.router.navigate(['/view'], { replaceUrl: true });
  1456. * ```
  1457. */
  1458. replaceUrl?: boolean;
  1459. /**
  1460. * Developer-defined state that can be passed to any navigation.
  1461. * Access this value through the `Navigation.extras` object
  1462. * returned from the [Router.getCurrentNavigation()
  1463. * method](api/router/Router#getcurrentnavigation) while a navigation is executing.
  1464. *
  1465. * After a navigation completes, the router writes an object containing this
  1466. * value together with a `navigationId` to `history.state`.
  1467. * The value is written when `location.go()` or `location.replaceState()`
  1468. * is called before activating this route.
  1469. *
  1470. * Note that `history.state` does not pass an object equality test because
  1471. * the router adds the `navigationId` on each navigation.
  1472. *
  1473. */
  1474. state?: {
  1475. [k: string]: any;
  1476. };
  1477. }
  1478. /**
  1479. * An event triggered when a navigation is canceled, directly or indirectly.
  1480. * This can happen for several reasons including when a route guard
  1481. * returns `false` or initiates a redirect by returning a `UrlTree`.
  1482. *
  1483. * @see `NavigationStart`
  1484. * @see `NavigationEnd`
  1485. * @see `NavigationError`
  1486. *
  1487. * @publicApi
  1488. */
  1489. export declare class NavigationCancel extends RouterEvent {
  1490. /**
  1491. * A description of why the navigation was cancelled. For debug purposes only. Use `code`
  1492. * instead for a stable cancellation reason that can be used in production.
  1493. */
  1494. reason: string;
  1495. /**
  1496. * A code to indicate why the navigation was canceled. This cancellation code is stable for
  1497. * the reason and can be relied on whereas the `reason` string could change and should not be
  1498. * used in production.
  1499. */
  1500. readonly code?: NavigationCancellationCode | undefined;
  1501. readonly type = EventType.NavigationCancel;
  1502. constructor(
  1503. /** @docsNotRequired */
  1504. id: number,
  1505. /** @docsNotRequired */
  1506. url: string,
  1507. /**
  1508. * A description of why the navigation was cancelled. For debug purposes only. Use `code`
  1509. * instead for a stable cancellation reason that can be used in production.
  1510. */
  1511. reason: string,
  1512. /**
  1513. * A code to indicate why the navigation was canceled. This cancellation code is stable for
  1514. * the reason and can be relied on whereas the `reason` string could change and should not be
  1515. * used in production.
  1516. */
  1517. code?: NavigationCancellationCode | undefined);
  1518. /** @docsNotRequired */
  1519. toString(): string;
  1520. }
  1521. /**
  1522. * A code for the `NavigationCancel` event of the `Router` to indicate the
  1523. * reason a navigation failed.
  1524. *
  1525. * @publicApi
  1526. */
  1527. export declare const enum NavigationCancellationCode {
  1528. /**
  1529. * A navigation failed because a guard returned a `UrlTree` to redirect.
  1530. */
  1531. Redirect = 0,
  1532. /**
  1533. * A navigation failed because a more recent navigation started.
  1534. */
  1535. SupersededByNewNavigation = 1,
  1536. /**
  1537. * A navigation failed because one of the resolvers completed without emitting a value.
  1538. */
  1539. NoDataFromResolver = 2,
  1540. /**
  1541. * A navigation failed because a guard returned `false`.
  1542. */
  1543. GuardRejected = 3
  1544. }
  1545. /**
  1546. * An event triggered when a navigation ends successfully.
  1547. *
  1548. * @see `NavigationStart`
  1549. * @see `NavigationCancel`
  1550. * @see `NavigationError`
  1551. *
  1552. * @publicApi
  1553. */
  1554. export declare class NavigationEnd extends RouterEvent {
  1555. /** @docsNotRequired */
  1556. urlAfterRedirects: string;
  1557. readonly type = EventType.NavigationEnd;
  1558. constructor(
  1559. /** @docsNotRequired */
  1560. id: number,
  1561. /** @docsNotRequired */
  1562. url: string,
  1563. /** @docsNotRequired */
  1564. urlAfterRedirects: string);
  1565. /** @docsNotRequired */
  1566. toString(): string;
  1567. }
  1568. /**
  1569. * An event triggered when a navigation fails due to an unexpected error.
  1570. *
  1571. * @see `NavigationStart`
  1572. * @see `NavigationEnd`
  1573. * @see `NavigationCancel`
  1574. *
  1575. * @publicApi
  1576. */
  1577. export declare class NavigationError extends RouterEvent {
  1578. /** @docsNotRequired */
  1579. error: any;
  1580. /**
  1581. * The target of the navigation when the error occurred.
  1582. *
  1583. * Note that this can be `undefined` because an error could have occurred before the
  1584. * `RouterStateSnapshot` was created for the navigation.
  1585. */
  1586. readonly target?: RouterStateSnapshot | undefined;
  1587. readonly type = EventType.NavigationError;
  1588. constructor(
  1589. /** @docsNotRequired */
  1590. id: number,
  1591. /** @docsNotRequired */
  1592. url: string,
  1593. /** @docsNotRequired */
  1594. error: any,
  1595. /**
  1596. * The target of the navigation when the error occurred.
  1597. *
  1598. * Note that this can be `undefined` because an error could have occurred before the
  1599. * `RouterStateSnapshot` was created for the navigation.
  1600. */
  1601. target?: RouterStateSnapshot | undefined);
  1602. /** @docsNotRequired */
  1603. toString(): string;
  1604. }
  1605. /**
  1606. * A type alias for providers returned by `withNavigationErrorHandler` for use with `provideRouter`.
  1607. *
  1608. * @see `withNavigationErrorHandler`
  1609. * @see `provideRouter`
  1610. *
  1611. * @publicApi
  1612. */
  1613. export declare type NavigationErrorHandlerFeature = RouterFeature<RouterFeatureKind.NavigationErrorHandlerFeature>;
  1614. /**
  1615. * @description
  1616. *
  1617. * Options that modify the `Router` navigation strategy.
  1618. * Supply an object containing any of these properties to a `Router` navigation function to
  1619. * control how the target URL should be constructed or interpreted.
  1620. *
  1621. * @see [Router.navigate() method](api/router/Router#navigate)
  1622. * @see [Router.navigateByUrl() method](api/router/Router#navigatebyurl)
  1623. * @see [Router.createUrlTree() method](api/router/Router#createurltree)
  1624. * @see [Routing and Navigation guide](guide/router)
  1625. * @see UrlCreationOptions
  1626. * @see NavigationBehaviorOptions
  1627. *
  1628. * @publicApi
  1629. */
  1630. export declare interface NavigationExtras extends UrlCreationOptions, NavigationBehaviorOptions {
  1631. }
  1632. /**
  1633. * An event triggered when a navigation is skipped.
  1634. * This can happen for a couple reasons including onSameUrlHandling
  1635. * is set to `ignore` and the navigation URL is not different than the
  1636. * current state.
  1637. *
  1638. * @publicApi
  1639. */
  1640. export declare class NavigationSkipped extends RouterEvent {
  1641. /**
  1642. * A description of why the navigation was skipped. For debug purposes only. Use `code`
  1643. * instead for a stable skipped reason that can be used in production.
  1644. */
  1645. reason: string;
  1646. /**
  1647. * A code to indicate why the navigation was skipped. This code is stable for
  1648. * the reason and can be relied on whereas the `reason` string could change and should not be
  1649. * used in production.
  1650. */
  1651. readonly code?: NavigationSkippedCode | undefined;
  1652. readonly type = EventType.NavigationSkipped;
  1653. constructor(
  1654. /** @docsNotRequired */
  1655. id: number,
  1656. /** @docsNotRequired */
  1657. url: string,
  1658. /**
  1659. * A description of why the navigation was skipped. For debug purposes only. Use `code`
  1660. * instead for a stable skipped reason that can be used in production.
  1661. */
  1662. reason: string,
  1663. /**
  1664. * A code to indicate why the navigation was skipped. This code is stable for
  1665. * the reason and can be relied on whereas the `reason` string could change and should not be
  1666. * used in production.
  1667. */
  1668. code?: NavigationSkippedCode | undefined);
  1669. }
  1670. /**
  1671. * A code for the `NavigationSkipped` event of the `Router` to indicate the
  1672. * reason a navigation was skipped.
  1673. *
  1674. * @publicApi
  1675. */
  1676. export declare const enum NavigationSkippedCode {
  1677. /**
  1678. * A navigation was skipped because the navigation URL was the same as the current Router URL.
  1679. */
  1680. IgnoredSameUrlNavigation = 0,
  1681. /**
  1682. * A navigation was skipped because the configured `UrlHandlingStrategy` return `false` for both
  1683. * the current Router URL and the target of the navigation.
  1684. *
  1685. * @see UrlHandlingStrategy
  1686. */
  1687. IgnoredByUrlHandlingStrategy = 1
  1688. }
  1689. /**
  1690. * An event triggered when a navigation starts.
  1691. *
  1692. * @publicApi
  1693. */
  1694. export declare class NavigationStart extends RouterEvent {
  1695. readonly type = EventType.NavigationStart;
  1696. /**
  1697. * Identifies the call or event that triggered the navigation.
  1698. * An `imperative` trigger is a call to `router.navigateByUrl()` or `router.navigate()`.
  1699. *
  1700. * @see `NavigationEnd`
  1701. * @see `NavigationCancel`
  1702. * @see `NavigationError`
  1703. */
  1704. navigationTrigger?: NavigationTrigger;
  1705. /**
  1706. * The navigation state that was previously supplied to the `pushState` call,
  1707. * when the navigation is triggered by a `popstate` event. Otherwise null.
  1708. *
  1709. * The state object is defined by `NavigationExtras`, and contains any
  1710. * developer-defined state value, as well as a unique ID that
  1711. * the router assigns to every router transition/navigation.
  1712. *
  1713. * From the perspective of the router, the router never "goes back".
  1714. * When the user clicks on the back button in the browser,
  1715. * a new navigation ID is created.
  1716. *
  1717. * Use the ID in this previous-state object to differentiate between a newly created
  1718. * state and one returned to by a `popstate` event, so that you can restore some
  1719. * remembered state, such as scroll position.
  1720. *
  1721. */
  1722. restoredState?: {
  1723. [k: string]: any;
  1724. navigationId: number;
  1725. } | null;
  1726. constructor(
  1727. /** @docsNotRequired */
  1728. id: number,
  1729. /** @docsNotRequired */
  1730. url: string,
  1731. /** @docsNotRequired */
  1732. navigationTrigger?: NavigationTrigger,
  1733. /** @docsNotRequired */
  1734. restoredState?: {
  1735. [k: string]: any;
  1736. navigationId: number;
  1737. } | null);
  1738. /** @docsNotRequired */
  1739. toString(): string;
  1740. }
  1741. /**
  1742. * Identifies the call or event that triggered a navigation.
  1743. *
  1744. * * 'imperative': Triggered by `router.navigateByUrl()` or `router.navigate()`.
  1745. * * 'popstate' : Triggered by a `popstate` event.
  1746. * * 'hashchange'-: Triggered by a `hashchange` event.
  1747. *
  1748. * @publicApi
  1749. */
  1750. declare type NavigationTrigger = 'imperative' | 'popstate' | 'hashchange';
  1751. /**
  1752. * @description
  1753. *
  1754. * Provides a preloading strategy that does not preload any modules.
  1755. *
  1756. * This strategy is enabled by default.
  1757. *
  1758. * @publicApi
  1759. */
  1760. export declare class NoPreloading implements PreloadingStrategy {
  1761. preload(route: Route, fn: () => Observable<any>): Observable<any>;
  1762. static ɵfac: i0.ɵɵFactoryDeclaration<NoPreloading, never>;
  1763. static ɵprov: i0.ɵɵInjectableDeclaration<NoPreloading>;
  1764. }
  1765. /**
  1766. * How to handle a navigation request to the current URL. One of:
  1767. *
  1768. * - `'ignore'` : The router ignores the request it is the same as the current state.
  1769. * - `'reload'` : The router processes the URL even if it is not different from the current state.
  1770. * One example of when you might want this option is if a `canMatch` guard depends on
  1771. * application state and initially rejects navigation to a route. After fixing the state, you want
  1772. * to re-navigate to the same URL so the route with the `canMatch` guard can activate.
  1773. *
  1774. * Note that this only configures whether the Route reprocesses the URL and triggers related
  1775. * action and events like redirects, guards, and resolvers. By default, the router re-uses a
  1776. * component instance when it re-navigates to the same component type without visiting a different
  1777. * component first. This behavior is configured by the `RouteReuseStrategy`. In order to reload
  1778. * routed components on same url navigation, you need to set `onSameUrlNavigation` to `'reload'`
  1779. * _and_ provide a `RouteReuseStrategy` which returns `false` for `shouldReuseRoute`. Additionally,
  1780. * resolvers and most guards for routes do not run unless the path or path params changed
  1781. * (configured by `runGuardsAndResolvers`).
  1782. *
  1783. * @publicApi
  1784. * @see `RouteReuseStrategy`
  1785. * @see `RunGuardsAndResolvers`
  1786. * @see `NavigationBehaviorOptions`
  1787. * @see `RouterConfigOptions`
  1788. */
  1789. export declare type OnSameUrlNavigation = 'reload' | 'ignore';
  1790. /**
  1791. * Store contextual information about a `RouterOutlet`
  1792. *
  1793. * @publicApi
  1794. */
  1795. export declare class OutletContext {
  1796. outlet: RouterOutletContract | null;
  1797. route: ActivatedRoute | null;
  1798. injector: EnvironmentInjector | null;
  1799. children: ChildrenOutletContexts;
  1800. attachRef: ComponentRef<any> | null;
  1801. }
  1802. /**
  1803. * A map that provides access to the required and optional parameters
  1804. * specific to a route.
  1805. * The map supports retrieving a single value with `get()`
  1806. * or multiple values with `getAll()`.
  1807. *
  1808. * @see [URLSearchParams](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams)
  1809. *
  1810. * @publicApi
  1811. */
  1812. export declare interface ParamMap {
  1813. /**
  1814. * Reports whether the map contains a given parameter.
  1815. * @param name The parameter name.
  1816. * @returns True if the map contains the given parameter, false otherwise.
  1817. */
  1818. has(name: string): boolean;
  1819. /**
  1820. * Retrieves a single value for a parameter.
  1821. * @param name The parameter name.
  1822. * @return The parameter's single value,
  1823. * or the first value if the parameter has multiple values,
  1824. * or `null` when there is no such parameter.
  1825. */
  1826. get(name: string): string | null;
  1827. /**
  1828. * Retrieves multiple values for a parameter.
  1829. * @param name The parameter name.
  1830. * @return An array containing one or more values,
  1831. * or an empty array if there is no such parameter.
  1832. *
  1833. */
  1834. getAll(name: string): string[];
  1835. /** Names of the parameters in the map. */
  1836. readonly keys: string[];
  1837. }
  1838. /**
  1839. * A collection of matrix and query URL parameters.
  1840. * @see `convertToParamMap()`
  1841. * @see `ParamMap`
  1842. *
  1843. * @publicApi
  1844. */
  1845. export declare type Params = {
  1846. [key: string]: any;
  1847. };
  1848. /**
  1849. * @description
  1850. *
  1851. * Provides a preloading strategy that preloads all modules as quickly as possible.
  1852. *
  1853. * ```
  1854. * RouterModule.forRoot(ROUTES, {preloadingStrategy: PreloadAllModules})
  1855. * ```
  1856. *
  1857. * @publicApi
  1858. */
  1859. export declare class PreloadAllModules implements PreloadingStrategy {
  1860. preload(route: Route, fn: () => Observable<any>): Observable<any>;
  1861. static ɵfac: i0.ɵɵFactoryDeclaration<PreloadAllModules, never>;
  1862. static ɵprov: i0.ɵɵInjectableDeclaration<PreloadAllModules>;
  1863. }
  1864. /**
  1865. * A type alias that represents a feature which enables preloading in Router.
  1866. * The type is used to describe the return value of the `withPreloading` function.
  1867. *
  1868. * @see `withPreloading`
  1869. * @see `provideRouter`
  1870. *
  1871. * @publicApi
  1872. */
  1873. export declare type PreloadingFeature = RouterFeature<RouterFeatureKind.PreloadingFeature>;
  1874. /**
  1875. * @description
  1876. *
  1877. * Provides a preloading strategy.
  1878. *
  1879. * @publicApi
  1880. */
  1881. export declare abstract class PreloadingStrategy {
  1882. abstract preload(route: Route, fn: () => Observable<any>): Observable<any>;
  1883. }
  1884. /**
  1885. * The primary routing outlet.
  1886. *
  1887. * @publicApi
  1888. */
  1889. export declare const PRIMARY_OUTLET = "primary";
  1890. /**
  1891. * Sets up providers necessary to enable `Router` functionality for the application.
  1892. * Allows to configure a set of routes as well as extra features that should be enabled.
  1893. *
  1894. * @usageNotes
  1895. *
  1896. * Basic example of how you can add a Router to your application:
  1897. * ```
  1898. * const appRoutes: Routes = [];
  1899. * bootstrapApplication(AppComponent, {
  1900. * providers: [provideRouter(appRoutes)]
  1901. * });
  1902. * ```
  1903. *
  1904. * You can also enable optional features in the Router by adding functions from the `RouterFeatures`
  1905. * type:
  1906. * ```
  1907. * const appRoutes: Routes = [];
  1908. * bootstrapApplication(AppComponent,
  1909. * {
  1910. * providers: [
  1911. * provideRouter(appRoutes,
  1912. * withDebugTracing(),
  1913. * withRouterConfig({paramsInheritanceStrategy: 'always'}))
  1914. * ]
  1915. * }
  1916. * );
  1917. * ```
  1918. *
  1919. * @see `RouterFeatures`
  1920. *
  1921. * @publicApi
  1922. * @param routes A set of `Route`s to use for the application routing table.
  1923. * @param features Optional features to configure additional router behaviors.
  1924. * @returns A set of providers to setup a Router.
  1925. */
  1926. export declare function provideRouter(routes: Routes, ...features: RouterFeatures[]): EnvironmentProviders;
  1927. /**
  1928. * Registers a [DI provider](guide/glossary#provider) for a set of routes.
  1929. * @param routes The route configuration to provide.
  1930. *
  1931. * @usageNotes
  1932. *
  1933. * ```
  1934. * @NgModule({
  1935. * providers: [provideRoutes(ROUTES)]
  1936. * })
  1937. * class LazyLoadedChildModule {}
  1938. * ```
  1939. *
  1940. * @deprecated If necessary, provide routes using the `ROUTES` `InjectionToken`.
  1941. * @see `ROUTES`
  1942. * @publicApi
  1943. */
  1944. export declare function provideRoutes(routes: Routes): Provider[];
  1945. /**
  1946. *
  1947. * How to handle query parameters in a router link.
  1948. * One of:
  1949. * - `"merge"` : Merge new parameters with current parameters.
  1950. * - `"preserve"` : Preserve current parameters.
  1951. * - `""` : Replace current parameters with new parameters. This is the default behavior.
  1952. *
  1953. * @see `UrlCreationOptions#queryParamsHandling`
  1954. * @see `RouterLink`
  1955. * @publicApi
  1956. */
  1957. export declare type QueryParamsHandling = 'merge' | 'preserve' | '';
  1958. /**
  1959. * @description
  1960. *
  1961. * Interface that classes can implement to be a data provider.
  1962. * A data provider class can be used with the router to resolve data during navigation.
  1963. * The interface defines a `resolve()` method that is invoked right after the `ResolveStart`
  1964. * router event. The router waits for the data to be resolved before the route is finally activated.
  1965. *
  1966. * The following example implements a `resolve()` method that retrieves the data
  1967. * needed to activate the requested route.
  1968. *
  1969. * ```
  1970. * @Injectable({ providedIn: 'root' })
  1971. * export class HeroResolver implements Resolve<Hero> {
  1972. * constructor(private service: HeroService) {}
  1973. *
  1974. * resolve(
  1975. * route: ActivatedRouteSnapshot,
  1976. * state: RouterStateSnapshot
  1977. * ): Observable<Hero>|Promise<Hero>|Hero {
  1978. * return this.service.getHero(route.paramMap.get('id'));
  1979. * }
  1980. * }
  1981. * ```
  1982. *
  1983. * Here, the defined `resolve()` function is provided as part of the `Route` object
  1984. * in the router configuration:
  1985. *
  1986. * ```
  1987. * @NgModule({
  1988. * imports: [
  1989. * RouterModule.forRoot([
  1990. * {
  1991. * path: 'detail/:id',
  1992. * component: HeroDetailComponent,
  1993. * resolve: {
  1994. * hero: HeroResolver
  1995. * }
  1996. * }
  1997. * ])
  1998. * ],
  1999. * exports: [RouterModule]
  2000. * })
  2001. * export class AppRoutingModule {}
  2002. * ```
  2003. *
  2004. * And you can access to your resolved data from `HeroComponent`:
  2005. *
  2006. * ```
  2007. * @Component({
  2008. * selector: "app-hero",
  2009. * templateUrl: "hero.component.html",
  2010. * })
  2011. * export class HeroComponent {
  2012. *
  2013. * constructor(private activatedRoute: ActivatedRoute) {}
  2014. *
  2015. * ngOnInit() {
  2016. * this.activatedRoute.data.subscribe(({ hero }) => {
  2017. * // do something with your resolved data ...
  2018. * })
  2019. * }
  2020. *
  2021. * }
  2022. * ```
  2023. *
  2024. * @usageNotes
  2025. *
  2026. * When both guard and resolvers are specified, the resolvers are not executed until
  2027. * all guards have run and succeeded.
  2028. * For example, consider the following route configuration:
  2029. *
  2030. * ```
  2031. * {
  2032. * path: 'base'
  2033. * canActivate: [BaseGuard],
  2034. * resolve: {data: BaseDataResolver}
  2035. * children: [
  2036. * {
  2037. * path: 'child',
  2038. * guards: [ChildGuard],
  2039. * component: ChildComponent,
  2040. * resolve: {childData: ChildDataResolver}
  2041. * }
  2042. * ]
  2043. * }
  2044. * ```
  2045. * The order of execution is: BaseGuard, ChildGuard, BaseDataResolver, ChildDataResolver.
  2046. *
  2047. * @publicApi
  2048. * @deprecated Class-based `Route` resolvers are deprecated in favor of functional resolvers. An
  2049. * injectable class can be used as a functional guard using the `inject` function: `resolve:
  2050. * {'user': () => inject(UserResolver).resolve()}`.
  2051. * @see `ResolveFn`
  2052. */
  2053. export declare interface Resolve<T> {
  2054. resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<T> | Promise<T> | T;
  2055. }
  2056. /**
  2057. *
  2058. * Represents the resolved data associated with a particular route.
  2059. *
  2060. * @see `Route#resolve`.
  2061. *
  2062. * @publicApi
  2063. */
  2064. export declare type ResolveData = {
  2065. [key: string | symbol]: ResolveFn<unknown> | DeprecatedGuard;
  2066. };
  2067. /**
  2068. * An event triggered at the end of the Resolve phase of routing.
  2069. * @see `ResolveStart`.
  2070. *
  2071. * @publicApi
  2072. */
  2073. export declare class ResolveEnd extends RouterEvent {
  2074. /** @docsNotRequired */
  2075. urlAfterRedirects: string;
  2076. /** @docsNotRequired */
  2077. state: RouterStateSnapshot;
  2078. readonly type = EventType.ResolveEnd;
  2079. constructor(
  2080. /** @docsNotRequired */
  2081. id: number,
  2082. /** @docsNotRequired */
  2083. url: string,
  2084. /** @docsNotRequired */
  2085. urlAfterRedirects: string,
  2086. /** @docsNotRequired */
  2087. state: RouterStateSnapshot);
  2088. toString(): string;
  2089. }
  2090. /**
  2091. * Function type definition for a data provider.
  2092. * A data provider can be used with the router to resolve data during navigation.
  2093. * The router waits for the data to be resolved before the route is finally activated.
  2094. *
  2095. * The following example implements a function that retrieves the data
  2096. * needed to activate the requested route.
  2097. *
  2098. * {@example router/route_functional_guards.ts region="ResolveFn"}
  2099. *
  2100. * And you can access to your resolved data from `HeroComponent`:
  2101. *
  2102. * {@example router/route_functional_guards.ts region="ResolveDataUse"}
  2103. *
  2104. * @usageNotes
  2105. *
  2106. * When both guard and resolvers are specified, the resolvers are not executed until
  2107. * all guards have run and succeeded.
  2108. * For example, consider the following route configuration:
  2109. *
  2110. * ```
  2111. * {
  2112. * path: 'base'
  2113. * canActivate: [baseGuard],
  2114. * resolve: {data: baseDataResolver}
  2115. * children: [
  2116. * {
  2117. * path: 'child',
  2118. * canActivate: [childGuard],
  2119. * component: ChildComponent,
  2120. * resolve: {childData: childDataResolver}
  2121. * }
  2122. * ]
  2123. * }
  2124. * ```
  2125. * The order of execution is: baseGuard, childGuard, baseDataResolver, childDataResolver.
  2126. *
  2127. * @publicApi
  2128. * @see `Route`
  2129. */
  2130. export declare type ResolveFn<T> = (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) => Observable<T> | Promise<T> | T;
  2131. /**
  2132. * An event triggered at the start of the Resolve phase of routing.
  2133. *
  2134. * Runs in the "resolve" phase whether or not there is anything to resolve.
  2135. * In future, may change to only run when there are things to be resolved.
  2136. *
  2137. * @see `ResolveEnd`
  2138. *
  2139. * @publicApi
  2140. */
  2141. export declare class ResolveStart extends RouterEvent {
  2142. /** @docsNotRequired */
  2143. urlAfterRedirects: string;
  2144. /** @docsNotRequired */
  2145. state: RouterStateSnapshot;
  2146. readonly type = EventType.ResolveStart;
  2147. constructor(
  2148. /** @docsNotRequired */
  2149. id: number,
  2150. /** @docsNotRequired */
  2151. url: string,
  2152. /** @docsNotRequired */
  2153. urlAfterRedirects: string,
  2154. /** @docsNotRequired */
  2155. state: RouterStateSnapshot);
  2156. toString(): string;
  2157. }
  2158. /**
  2159. * A configuration object that defines a single route.
  2160. * A set of routes are collected in a `Routes` array to define a `Router` configuration.
  2161. * The router attempts to match segments of a given URL against each route,
  2162. * using the configuration options defined in this object.
  2163. *
  2164. * Supports static, parameterized, redirect, and wildcard routes, as well as
  2165. * custom route data and resolve methods.
  2166. *
  2167. * For detailed usage information, see the [Routing Guide](guide/router).
  2168. *
  2169. * @usageNotes
  2170. *
  2171. * ### Simple Configuration
  2172. *
  2173. * The following route specifies that when navigating to, for example,
  2174. * `/team/11/user/bob`, the router creates the 'Team' component
  2175. * with the 'User' child component in it.
  2176. *
  2177. * ```
  2178. * [{
  2179. * path: 'team/:id',
  2180. * component: Team,
  2181. * children: [{
  2182. * path: 'user/:name',
  2183. * component: User
  2184. * }]
  2185. * }]
  2186. * ```
  2187. *
  2188. * ### Multiple Outlets
  2189. *
  2190. * The following route creates sibling components with multiple outlets.
  2191. * When navigating to `/team/11(aux:chat/jim)`, the router creates the 'Team' component next to
  2192. * the 'Chat' component. The 'Chat' component is placed into the 'aux' outlet.
  2193. *
  2194. * ```
  2195. * [{
  2196. * path: 'team/:id',
  2197. * component: Team
  2198. * }, {
  2199. * path: 'chat/:user',
  2200. * component: Chat
  2201. * outlet: 'aux'
  2202. * }]
  2203. * ```
  2204. *
  2205. * ### Wild Cards
  2206. *
  2207. * The following route uses wild-card notation to specify a component
  2208. * that is always instantiated regardless of where you navigate to.
  2209. *
  2210. * ```
  2211. * [{
  2212. * path: '**',
  2213. * component: WildcardComponent
  2214. * }]
  2215. * ```
  2216. *
  2217. * ### Redirects
  2218. *
  2219. * The following route uses the `redirectTo` property to ignore a segment of
  2220. * a given URL when looking for a child path.
  2221. *
  2222. * When navigating to '/team/11/legacy/user/jim', the router changes the URL segment
  2223. * '/team/11/legacy/user/jim' to '/team/11/user/jim', and then instantiates
  2224. * the Team component with the User child component in it.
  2225. *
  2226. * ```
  2227. * [{
  2228. * path: 'team/:id',
  2229. * component: Team,
  2230. * children: [{
  2231. * path: 'legacy/user/:name',
  2232. * redirectTo: 'user/:name'
  2233. * }, {
  2234. * path: 'user/:name',
  2235. * component: User
  2236. * }]
  2237. * }]
  2238. * ```
  2239. *
  2240. * The redirect path can be relative, as shown in this example, or absolute.
  2241. * If we change the `redirectTo` value in the example to the absolute URL segment '/user/:name',
  2242. * the result URL is also absolute, '/user/jim'.
  2243. * ### Empty Path
  2244. *
  2245. * Empty-path route configurations can be used to instantiate components that do not 'consume'
  2246. * any URL segments.
  2247. *
  2248. * In the following configuration, when navigating to
  2249. * `/team/11`, the router instantiates the 'AllUsers' component.
  2250. *
  2251. * ```
  2252. * [{
  2253. * path: 'team/:id',
  2254. * component: Team,
  2255. * children: [{
  2256. * path: '',
  2257. * component: AllUsers
  2258. * }, {
  2259. * path: 'user/:name',
  2260. * component: User
  2261. * }]
  2262. * }]
  2263. * ```
  2264. *
  2265. * Empty-path routes can have children. In the following example, when navigating
  2266. * to `/team/11/user/jim`, the router instantiates the wrapper component with
  2267. * the user component in it.
  2268. *
  2269. * Note that an empty path route inherits its parent's parameters and data.
  2270. *
  2271. * ```
  2272. * [{
  2273. * path: 'team/:id',
  2274. * component: Team,
  2275. * children: [{
  2276. * path: '',
  2277. * component: WrapperCmp,
  2278. * children: [{
  2279. * path: 'user/:name',
  2280. * component: User
  2281. * }]
  2282. * }]
  2283. * }]
  2284. * ```
  2285. *
  2286. * ### Matching Strategy
  2287. *
  2288. * The default path-match strategy is 'prefix', which means that the router
  2289. * checks URL elements from the left to see if the URL matches a specified path.
  2290. * For example, '/team/11/user' matches 'team/:id'.
  2291. *
  2292. * ```
  2293. * [{
  2294. * path: '',
  2295. * pathMatch: 'prefix', //default
  2296. * redirectTo: 'main'
  2297. * }, {
  2298. * path: 'main',
  2299. * component: Main
  2300. * }]
  2301. * ```
  2302. *
  2303. * You can specify the path-match strategy 'full' to make sure that the path
  2304. * covers the whole unconsumed URL. It is important to do this when redirecting
  2305. * empty-path routes. Otherwise, because an empty path is a prefix of any URL,
  2306. * the router would apply the redirect even when navigating to the redirect destination,
  2307. * creating an endless loop.
  2308. *
  2309. * In the following example, supplying the 'full' `pathMatch` strategy ensures
  2310. * that the router applies the redirect if and only if navigating to '/'.
  2311. *
  2312. * ```
  2313. * [{
  2314. * path: '',
  2315. * pathMatch: 'full',
  2316. * redirectTo: 'main'
  2317. * }, {
  2318. * path: 'main',
  2319. * component: Main
  2320. * }]
  2321. * ```
  2322. *
  2323. * ### Componentless Routes
  2324. *
  2325. * You can share parameters between sibling components.
  2326. * For example, suppose that two sibling components should go next to each other,
  2327. * and both of them require an ID parameter. You can accomplish this using a route
  2328. * that does not specify a component at the top level.
  2329. *
  2330. * In the following example, 'MainChild' and 'AuxChild' are siblings.
  2331. * When navigating to 'parent/10/(a//aux:b)', the route instantiates
  2332. * the main child and aux child components next to each other.
  2333. * For this to work, the application component must have the primary and aux outlets defined.
  2334. *
  2335. * ```
  2336. * [{
  2337. * path: 'parent/:id',
  2338. * children: [
  2339. * { path: 'a', component: MainChild },
  2340. * { path: 'b', component: AuxChild, outlet: 'aux' }
  2341. * ]
  2342. * }]
  2343. * ```
  2344. *
  2345. * The router merges the parameters, data, and resolve of the componentless
  2346. * parent into the parameters, data, and resolve of the children.
  2347. *
  2348. * This is especially useful when child components are defined
  2349. * with an empty path string, as in the following example.
  2350. * With this configuration, navigating to '/parent/10' creates
  2351. * the main child and aux components.
  2352. *
  2353. * ```
  2354. * [{
  2355. * path: 'parent/:id',
  2356. * children: [
  2357. * { path: '', component: MainChild },
  2358. * { path: '', component: AuxChild, outlet: 'aux' }
  2359. * ]
  2360. * }]
  2361. * ```
  2362. *
  2363. * ### Lazy Loading
  2364. *
  2365. * Lazy loading speeds up application load time by splitting the application
  2366. * into multiple bundles and loading them on demand.
  2367. * To use lazy loading, provide the `loadChildren` property in the `Route` object,
  2368. * instead of the `children` property.
  2369. *
  2370. * Given the following example route, the router will lazy load
  2371. * the associated module on demand using the browser native import system.
  2372. *
  2373. * ```
  2374. * [{
  2375. * path: 'lazy',
  2376. * loadChildren: () => import('./lazy-route/lazy.module').then(mod => mod.LazyModule),
  2377. * }];
  2378. * ```
  2379. *
  2380. * @publicApi
  2381. */
  2382. export declare interface Route {
  2383. /**
  2384. * Used to define a page title for the route. This can be a static string or an `Injectable` that
  2385. * implements `Resolve`.
  2386. *
  2387. * @see `PageTitleStrategy`
  2388. */
  2389. title?: string | Type<Resolve<string>> | ResolveFn<string>;
  2390. /**
  2391. * The path to match against. Cannot be used together with a custom `matcher` function.
  2392. * A URL string that uses router matching notation.
  2393. * Can be a wild card (`**`) that matches any URL (see Usage Notes below).
  2394. * Default is "/" (the root path).
  2395. *
  2396. */
  2397. path?: string;
  2398. /**
  2399. * The path-matching strategy, one of 'prefix' or 'full'.
  2400. * Default is 'prefix'.
  2401. *
  2402. * By default, the router checks URL elements from the left to see if the URL
  2403. * matches a given path and stops when there is a config match. Importantly there must still be a
  2404. * config match for each segment of the URL. For example, '/team/11/user' matches the prefix
  2405. * 'team/:id' if one of the route's children matches the segment 'user'. That is, the URL
  2406. * '/team/11/user' matches the config
  2407. * `{path: 'team/:id', children: [{path: ':user', component: User}]}`
  2408. * but does not match when there are no children as in `{path: 'team/:id', component: Team}`.
  2409. *
  2410. * The path-match strategy 'full' matches against the entire URL.
  2411. * It is important to do this when redirecting empty-path routes.
  2412. * Otherwise, because an empty path is a prefix of any URL,
  2413. * the router would apply the redirect even when navigating
  2414. * to the redirect destination, creating an endless loop.
  2415. *
  2416. */
  2417. pathMatch?: 'prefix' | 'full';
  2418. /**
  2419. * A custom URL-matching function. Cannot be used together with `path`.
  2420. */
  2421. matcher?: UrlMatcher;
  2422. /**
  2423. * The component to instantiate when the path matches.
  2424. * Can be empty if child routes specify components.
  2425. */
  2426. component?: Type<any>;
  2427. /**
  2428. * An object specifying a lazy-loaded component.
  2429. */
  2430. loadComponent?: () => Type<unknown> | Observable<Type<unknown> | DefaultExport<Type<unknown>>> | Promise<Type<unknown> | DefaultExport<Type<unknown>>>;
  2431. /**
  2432. * A URL to redirect to when the path matches.
  2433. *
  2434. * Absolute if the URL begins with a slash (/), otherwise relative to the path URL.
  2435. * Note that no further redirects are evaluated after an absolute redirect.
  2436. *
  2437. * When not present, router does not redirect.
  2438. */
  2439. redirectTo?: string;
  2440. /**
  2441. * Name of a `RouterOutlet` object where the component can be placed
  2442. * when the path matches.
  2443. */
  2444. outlet?: string;
  2445. /**
  2446. * An array of `CanActivateFn` or DI tokens used to look up `CanActivate()`
  2447. * handlers, in order to determine if the current user is allowed to
  2448. * activate the component. By default, any user can activate.
  2449. *
  2450. * When using a function rather than DI tokens, the function can call `inject` to get any required
  2451. * dependencies. This `inject` call must be done in a synchronous context.
  2452. */
  2453. canActivate?: Array<CanActivateFn | DeprecatedGuard>;
  2454. /**
  2455. * An array of `CanMatchFn` or DI tokens used to look up `CanMatch()`
  2456. * handlers, in order to determine if the current user is allowed to
  2457. * match the `Route`. By default, any route can match.
  2458. *
  2459. * When using a function rather than DI tokens, the function can call `inject` to get any required
  2460. * dependencies. This `inject` call must be done in a synchronous context.
  2461. */
  2462. canMatch?: Array<CanMatchFn | DeprecatedGuard>;
  2463. /**
  2464. * An array of `CanActivateChildFn` or DI tokens used to look up `CanActivateChild()` handlers,
  2465. * in order to determine if the current user is allowed to activate
  2466. * a child of the component. By default, any user can activate a child.
  2467. *
  2468. * When using a function rather than DI tokens, the function can call `inject` to get any required
  2469. * dependencies. This `inject` call must be done in a synchronous context.
  2470. */
  2471. canActivateChild?: Array<CanActivateChildFn | DeprecatedGuard>;
  2472. /**
  2473. * An array of `CanDeactivateFn` or DI tokens used to look up `CanDeactivate()`
  2474. * handlers, in order to determine if the current user is allowed to
  2475. * deactivate the component. By default, any user can deactivate.
  2476. *
  2477. * When using a function rather than DI tokens, the function can call `inject` to get any required
  2478. * dependencies. This `inject` call must be done in a synchronous context.
  2479. */
  2480. canDeactivate?: Array<CanDeactivateFn<any> | DeprecatedGuard>;
  2481. /**
  2482. * An array of `CanLoadFn` or DI tokens used to look up `CanLoad()`
  2483. * handlers, in order to determine if the current user is allowed to
  2484. * load the component. By default, any user can load.
  2485. *
  2486. * When using a function rather than DI tokens, the function can call `inject` to get any required
  2487. * dependencies. This `inject` call must be done in a synchronous context.
  2488. * @deprecated Use `canMatch` instead
  2489. */
  2490. canLoad?: Array<CanLoadFn | DeprecatedGuard>;
  2491. /**
  2492. * Additional developer-defined data provided to the component via
  2493. * `ActivatedRoute`. By default, no additional data is passed.
  2494. */
  2495. data?: Data;
  2496. /**
  2497. * A map of DI tokens used to look up data resolvers. See `Resolve`.
  2498. */
  2499. resolve?: ResolveData;
  2500. /**
  2501. * An array of child `Route` objects that specifies a nested route
  2502. * configuration.
  2503. */
  2504. children?: Routes;
  2505. /**
  2506. * An object specifying lazy-loaded child routes.
  2507. */
  2508. loadChildren?: LoadChildren;
  2509. /**
  2510. * A policy for when to run guards and resolvers on a route.
  2511. *
  2512. * Guards and/or resolvers will always run when a route is activated or deactivated. When a route
  2513. * is unchanged, the default behavior is the same as `paramsChange`.
  2514. *
  2515. * `paramsChange` : Rerun the guards and resolvers when path or
  2516. * path param changes. This does not include query parameters. This option is the default.
  2517. * - `always` : Run on every execution.
  2518. * - `pathParamsChange` : Rerun guards and resolvers when the path params
  2519. * change. This does not compare matrix or query parameters.
  2520. * - `paramsOrQueryParamsChange` : Run when path, matrix, or query parameters change.
  2521. * - `pathParamsOrQueryParamsChange` : Rerun guards and resolvers when the path params
  2522. * change or query params have changed. This does not include matrix parameters.
  2523. *
  2524. * @see `RunGuardsAndResolvers`
  2525. */
  2526. runGuardsAndResolvers?: RunGuardsAndResolvers;
  2527. /**
  2528. * A `Provider` array to use for this `Route` and its `children`.
  2529. *
  2530. * The `Router` will create a new `EnvironmentInjector` for this
  2531. * `Route` and use it for this `Route` and its `children`. If this
  2532. * route also has a `loadChildren` function which returns an `NgModuleRef`, this injector will be
  2533. * used as the parent of the lazy loaded module.
  2534. */
  2535. providers?: Array<Provider | EnvironmentProviders>;
  2536. }
  2537. /**
  2538. * An event triggered when a route has been lazy loaded.
  2539. *
  2540. * @see `RouteConfigLoadStart`
  2541. *
  2542. * @publicApi
  2543. */
  2544. export declare class RouteConfigLoadEnd {
  2545. /** @docsNotRequired */
  2546. route: Route;
  2547. readonly type = EventType.RouteConfigLoadEnd;
  2548. constructor(
  2549. /** @docsNotRequired */
  2550. route: Route);
  2551. toString(): string;
  2552. }
  2553. /**
  2554. * An event triggered before lazy loading a route configuration.
  2555. *
  2556. * @see `RouteConfigLoadEnd`
  2557. *
  2558. * @publicApi
  2559. */
  2560. export declare class RouteConfigLoadStart {
  2561. /** @docsNotRequired */
  2562. route: Route;
  2563. readonly type = EventType.RouteConfigLoadStart;
  2564. constructor(
  2565. /** @docsNotRequired */
  2566. route: Route);
  2567. toString(): string;
  2568. }
  2569. /**
  2570. * Injectable used as a tree-shakable provider for opting in to binding router data to component
  2571. * inputs.
  2572. *
  2573. * The RouterOutlet registers itself with this service when an `ActivatedRoute` is attached or
  2574. * activated. When this happens, the service subscribes to the `ActivatedRoute` observables (params,
  2575. * queryParams, data) and sets the inputs of the component using `ComponentRef.setInput`.
  2576. * Importantly, when an input does not have an item in the route data with a matching key, this
  2577. * input is set to `undefined`. If it were not done this way, the previous information would be
  2578. * retained if the data got removed from the route (i.e. if a query parameter is removed).
  2579. *
  2580. * The `RouterOutlet` should unregister itself when destroyed via `unsubscribeFromRouteData` so that
  2581. * the subscriptions are cleaned up.
  2582. */
  2583. declare class RoutedComponentInputBinder {
  2584. private outletDataSubscriptions;
  2585. bindActivatedRouteToOutletComponent(outlet: RouterOutlet): void;
  2586. unsubscribeFromRouteData(outlet: RouterOutlet): void;
  2587. private subscribeToRouteData;
  2588. static ɵfac: i0.ɵɵFactoryDeclaration<RoutedComponentInputBinder, never>;
  2589. static ɵprov: i0.ɵɵInjectableDeclaration<RoutedComponentInputBinder>;
  2590. }
  2591. /**
  2592. * @description
  2593. *
  2594. * A service that provides navigation among views and URL manipulation capabilities.
  2595. *
  2596. * @see `Route`.
  2597. * @see [Routing and Navigation Guide](guide/router).
  2598. *
  2599. * @ngModule RouterModule
  2600. *
  2601. * @publicApi
  2602. */
  2603. export declare class Router {
  2604. private disposed;
  2605. private locationSubscription?;
  2606. private get navigationId();
  2607. /**
  2608. * The id of the currently active page in the router.
  2609. * Updated to the transition's target id on a successful navigation.
  2610. *
  2611. * This is used to track what page the router last activated. When an attempted navigation fails,
  2612. * the router can then use this to compute how to restore the state back to the previously active
  2613. * page.
  2614. */
  2615. private currentPageId;
  2616. /**
  2617. * The ɵrouterPageId of whatever page is currently active in the browser history. This is
  2618. * important for computing the target page id for new navigations because we need to ensure each
  2619. * page id in the browser history is 1 more than the previous entry.
  2620. */
  2621. private get browserPageId();
  2622. private console;
  2623. private isNgZoneEnabled;
  2624. /**
  2625. * An event stream for routing events.
  2626. */
  2627. get events(): Observable<Event_2>;
  2628. /**
  2629. * The current state of routing in this NgModule.
  2630. */
  2631. readonly routerState: RouterState;
  2632. private options;
  2633. private pendingTasks;
  2634. /**
  2635. * A handler for navigation errors in this NgModule.
  2636. *
  2637. * @deprecated Subscribe to the `Router` events and watch for `NavigationError` instead.
  2638. * `provideRouter` has the `withNavigationErrorHandler` feature to make this easier.
  2639. * @see `withNavigationErrorHandler`
  2640. */
  2641. errorHandler: (error: any) => any;
  2642. /**
  2643. * A handler for errors thrown by `Router.parseUrl(url)`
  2644. * when `url` contains an invalid character.
  2645. * The most common case is a `%` sign
  2646. * that's not encoded and is not part of a percent encoded sequence.
  2647. *
  2648. * @deprecated URI parsing errors should be handled in the `UrlSerializer`.
  2649. *
  2650. * @see `RouterModule`
  2651. */
  2652. malformedUriErrorHandler: (error: URIError, urlSerializer: UrlSerializer, url: string) => UrlTree;
  2653. /**
  2654. * True if at least one navigation event has occurred,
  2655. * false otherwise.
  2656. */
  2657. navigated: boolean;
  2658. private lastSuccessfulId;
  2659. /**
  2660. * A strategy for extracting and merging URLs.
  2661. * Used for AngularJS to Angular migrations.
  2662. *
  2663. * @deprecated Configure using `providers` instead:
  2664. * `{provide: UrlHandlingStrategy, useClass: MyStrategy}`.
  2665. */
  2666. urlHandlingStrategy: UrlHandlingStrategy;
  2667. /**
  2668. * A strategy for re-using routes.
  2669. *
  2670. * @deprecated Configure using `providers` instead:
  2671. * `{provide: RouteReuseStrategy, useClass: MyStrategy}`.
  2672. */
  2673. routeReuseStrategy: RouteReuseStrategy;
  2674. /**
  2675. * A strategy for setting the title based on the `routerState`.
  2676. *
  2677. * @deprecated Configure using `providers` instead:
  2678. * `{provide: TitleStrategy, useClass: MyStrategy}`.
  2679. */
  2680. titleStrategy?: TitleStrategy;
  2681. /**
  2682. * How to handle a navigation request to the current URL.
  2683. *
  2684. *
  2685. * @deprecated Configure this through `provideRouter` or `RouterModule.forRoot` instead.
  2686. * @see `withRouterConfig`
  2687. * @see `provideRouter`
  2688. * @see `RouterModule`
  2689. */
  2690. onSameUrlNavigation: OnSameUrlNavigation;
  2691. /**
  2692. * How to merge parameters, data, resolved data, and title from parent to child
  2693. * routes. One of:
  2694. *
  2695. * - `'emptyOnly'` : Inherit parent parameters, data, and resolved data
  2696. * for path-less or component-less routes.
  2697. * - `'always'` : Inherit parent parameters, data, and resolved data
  2698. * for all child routes.
  2699. *
  2700. * @deprecated Configure this through `provideRouter` or `RouterModule.forRoot` instead.
  2701. * @see `withRouterConfig`
  2702. * @see `provideRouter`
  2703. * @see `RouterModule`
  2704. */
  2705. paramsInheritanceStrategy: 'emptyOnly' | 'always';
  2706. /**
  2707. * Determines when the router updates the browser URL.
  2708. * By default (`"deferred"`), updates the browser URL after navigation has finished.
  2709. * Set to `'eager'` to update the browser URL at the beginning of navigation.
  2710. * You can choose to update early so that, if navigation fails,
  2711. * you can show an error message with the URL that failed.
  2712. *
  2713. * @deprecated Configure this through `provideRouter` or `RouterModule.forRoot` instead.
  2714. * @see `withRouterConfig`
  2715. * @see `provideRouter`
  2716. * @see `RouterModule`
  2717. */
  2718. urlUpdateStrategy: 'deferred' | 'eager';
  2719. /**
  2720. * Configures how the Router attempts to restore state when a navigation is cancelled.
  2721. *
  2722. * 'replace' - Always uses `location.replaceState` to set the browser state to the state of the
  2723. * router before the navigation started. This means that if the URL of the browser is updated
  2724. * _before_ the navigation is canceled, the Router will simply replace the item in history rather
  2725. * than trying to restore to the previous location in the session history. This happens most
  2726. * frequently with `urlUpdateStrategy: 'eager'` and navigations with the browser back/forward
  2727. * buttons.
  2728. *
  2729. * 'computed' - Will attempt to return to the same index in the session history that corresponds
  2730. * to the Angular route when the navigation gets cancelled. For example, if the browser back
  2731. * button is clicked and the navigation is cancelled, the Router will trigger a forward navigation
  2732. * and vice versa.
  2733. *
  2734. * Note: the 'computed' option is incompatible with any `UrlHandlingStrategy` which only
  2735. * handles a portion of the URL because the history restoration navigates to the previous place in
  2736. * the browser history rather than simply resetting a portion of the URL.
  2737. *
  2738. * The default value is `replace`.
  2739. *
  2740. * @deprecated Configure this through `provideRouter` or `RouterModule.forRoot` instead.
  2741. * @see `withRouterConfig`
  2742. * @see `provideRouter`
  2743. * @see `RouterModule`
  2744. */
  2745. canceledNavigationResolution: 'replace' | 'computed';
  2746. config: Routes;
  2747. private readonly navigationTransitions;
  2748. private readonly urlSerializer;
  2749. private readonly location;
  2750. /**
  2751. * Indicates whether the the application has opted in to binding Router data to component inputs.
  2752. *
  2753. * This option is enabled by the `withComponentInputBinding` feature of `provideRouter` or
  2754. * `bindToComponentInputs` in the `ExtraOptions` of `RouterModule.forRoot`.
  2755. */
  2756. readonly componentInputBindingEnabled: boolean;
  2757. constructor();
  2758. /**
  2759. * Sets up the location change listener and performs the initial navigation.
  2760. */
  2761. initialNavigation(): void;
  2762. /**
  2763. * Sets up the location change listener. This listener detects navigations triggered from outside
  2764. * the Router (the browser back/forward buttons, for example) and schedules a corresponding Router
  2765. * navigation so that the correct events, guards, etc. are triggered.
  2766. */
  2767. setUpLocationChangeListener(): void;
  2768. /**
  2769. * Schedules a router navigation to synchronize Router state with the browser state.
  2770. *
  2771. * This is done as a response to a popstate event and the initial navigation. These
  2772. * two scenarios represent times when the browser URL/state has been updated and
  2773. * the Router needs to respond to ensure its internal state matches.
  2774. */
  2775. private navigateToSyncWithBrowser;
  2776. /** The current URL. */
  2777. get url(): string;
  2778. /**
  2779. * Returns the current `Navigation` object when the router is navigating,
  2780. * and `null` when idle.
  2781. */
  2782. getCurrentNavigation(): Navigation | null;
  2783. /**
  2784. * The `Navigation` object of the most recent navigation to succeed and `null` if there
  2785. * has not been a successful navigation yet.
  2786. */
  2787. get lastSuccessfulNavigation(): Navigation | null;
  2788. /**
  2789. * Resets the route configuration used for navigation and generating links.
  2790. *
  2791. * @param config The route array for the new configuration.
  2792. *
  2793. * @usageNotes
  2794. *
  2795. * ```
  2796. * router.resetConfig([
  2797. * { path: 'team/:id', component: TeamCmp, children: [
  2798. * { path: 'simple', component: SimpleCmp },
  2799. * { path: 'user/:name', component: UserCmp }
  2800. * ]}
  2801. * ]);
  2802. * ```
  2803. */
  2804. resetConfig(config: Routes): void;
  2805. /** @nodoc */
  2806. ngOnDestroy(): void;
  2807. /** Disposes of the router. */
  2808. dispose(): void;
  2809. /**
  2810. * Appends URL segments to the current URL tree to create a new URL tree.
  2811. *
  2812. * @param commands An array of URL fragments with which to construct the new URL tree.
  2813. * If the path is static, can be the literal URL string. For a dynamic path, pass an array of path
  2814. * segments, followed by the parameters for each segment.
  2815. * The fragments are applied to the current URL tree or the one provided in the `relativeTo`
  2816. * property of the options object, if supplied.
  2817. * @param navigationExtras Options that control the navigation strategy.
  2818. * @returns The new URL tree.
  2819. *
  2820. * @usageNotes
  2821. *
  2822. * ```
  2823. * // create /team/33/user/11
  2824. * router.createUrlTree(['/team', 33, 'user', 11]);
  2825. *
  2826. * // create /team/33;expand=true/user/11
  2827. * router.createUrlTree(['/team', 33, {expand: true}, 'user', 11]);
  2828. *
  2829. * // you can collapse static segments like this (this works only with the first passed-in value):
  2830. * router.createUrlTree(['/team/33/user', userId]);
  2831. *
  2832. * // If the first segment can contain slashes, and you do not want the router to split it,
  2833. * // you can do the following:
  2834. * router.createUrlTree([{segmentPath: '/one/two'}]);
  2835. *
  2836. * // create /team/33/(user/11//right:chat)
  2837. * router.createUrlTree(['/team', 33, {outlets: {primary: 'user/11', right: 'chat'}}]);
  2838. *
  2839. * // remove the right secondary node
  2840. * router.createUrlTree(['/team', 33, {outlets: {primary: 'user/11', right: null}}]);
  2841. *
  2842. * // assuming the current url is `/team/33/user/11` and the route points to `user/11`
  2843. *
  2844. * // navigate to /team/33/user/11/details
  2845. * router.createUrlTree(['details'], {relativeTo: route});
  2846. *
  2847. * // navigate to /team/33/user/22
  2848. * router.createUrlTree(['../22'], {relativeTo: route});
  2849. *
  2850. * // navigate to /team/44/user/22
  2851. * router.createUrlTree(['../../team/44/user/22'], {relativeTo: route});
  2852. *
  2853. * Note that a value of `null` or `undefined` for `relativeTo` indicates that the
  2854. * tree should be created relative to the root.
  2855. * ```
  2856. */
  2857. createUrlTree(commands: any[], navigationExtras?: UrlCreationOptions): UrlTree;
  2858. /**
  2859. * Navigates to a view using an absolute route path.
  2860. *
  2861. * @param url An absolute path for a defined route. The function does not apply any delta to the
  2862. * current URL.
  2863. * @param extras An object containing properties that modify the navigation strategy.
  2864. *
  2865. * @returns A Promise that resolves to 'true' when navigation succeeds,
  2866. * to 'false' when navigation fails, or is rejected on error.
  2867. *
  2868. * @usageNotes
  2869. *
  2870. * The following calls request navigation to an absolute path.
  2871. *
  2872. * ```
  2873. * router.navigateByUrl("/team/33/user/11");
  2874. *
  2875. * // Navigate without updating the URL
  2876. * router.navigateByUrl("/team/33/user/11", { skipLocationChange: true });
  2877. * ```
  2878. *
  2879. * @see [Routing and Navigation guide](guide/router)
  2880. *
  2881. */
  2882. navigateByUrl(url: string | UrlTree, extras?: NavigationBehaviorOptions): Promise<boolean>;
  2883. /**
  2884. * Navigate based on the provided array of commands and a starting point.
  2885. * If no starting route is provided, the navigation is absolute.
  2886. *
  2887. * @param commands An array of URL fragments with which to construct the target URL.
  2888. * If the path is static, can be the literal URL string. For a dynamic path, pass an array of path
  2889. * segments, followed by the parameters for each segment.
  2890. * The fragments are applied to the current URL or the one provided in the `relativeTo` property
  2891. * of the options object, if supplied.
  2892. * @param extras An options object that determines how the URL should be constructed or
  2893. * interpreted.
  2894. *
  2895. * @returns A Promise that resolves to `true` when navigation succeeds, to `false` when navigation
  2896. * fails,
  2897. * or is rejected on error.
  2898. *
  2899. * @usageNotes
  2900. *
  2901. * The following calls request navigation to a dynamic route path relative to the current URL.
  2902. *
  2903. * ```
  2904. * router.navigate(['team', 33, 'user', 11], {relativeTo: route});
  2905. *
  2906. * // Navigate without updating the URL, overriding the default behavior
  2907. * router.navigate(['team', 33, 'user', 11], {relativeTo: route, skipLocationChange: true});
  2908. * ```
  2909. *
  2910. * @see [Routing and Navigation guide](guide/router)
  2911. *
  2912. */
  2913. navigate(commands: any[], extras?: NavigationExtras): Promise<boolean>;
  2914. /** Serializes a `UrlTree` into a string */
  2915. serializeUrl(url: UrlTree): string;
  2916. /** Parses a string into a `UrlTree` */
  2917. parseUrl(url: string): UrlTree;
  2918. /**
  2919. * Returns whether the url is activated.
  2920. *
  2921. * @deprecated
  2922. * Use `IsActiveMatchOptions` instead.
  2923. *
  2924. * - The equivalent `IsActiveMatchOptions` for `true` is
  2925. * `{paths: 'exact', queryParams: 'exact', fragment: 'ignored', matrixParams: 'ignored'}`.
  2926. * - The equivalent for `false` is
  2927. * `{paths: 'subset', queryParams: 'subset', fragment: 'ignored', matrixParams: 'ignored'}`.
  2928. */
  2929. isActive(url: string | UrlTree, exact: boolean): boolean;
  2930. /**
  2931. * Returns whether the url is activated.
  2932. */
  2933. isActive(url: string | UrlTree, matchOptions: IsActiveMatchOptions): boolean;
  2934. private removeEmptyProps;
  2935. private resetState;
  2936. private resetUrlToCurrentUrlTree;
  2937. private generateNgRouterState;
  2938. static ɵfac: i0.ɵɵFactoryDeclaration<Router, never>;
  2939. static ɵprov: i0.ɵɵInjectableDeclaration<Router>;
  2940. }
  2941. /**
  2942. * A [DI token](guide/glossary/#di-token) for the router service.
  2943. *
  2944. * @publicApi
  2945. */
  2946. export declare const ROUTER_CONFIGURATION: InjectionToken<ExtraOptions>;
  2947. /**
  2948. * A [DI token](guide/glossary/#di-token) for the router initializer that
  2949. * is called after the app is bootstrapped.
  2950. *
  2951. * @publicApi
  2952. */
  2953. export declare const ROUTER_INITIALIZER: InjectionToken<(compRef: ComponentRef<any>) => void>;
  2954. declare class RouterConfigLoader {
  2955. private componentLoaders;
  2956. private childrenLoaders;
  2957. onLoadStartListener?: (r: Route) => void;
  2958. onLoadEndListener?: (r: Route) => void;
  2959. private readonly compiler;
  2960. loadComponent(route: Route): Observable<Type<unknown>>;
  2961. loadChildren(parentInjector: Injector, route: Route): Observable<LoadedRouterConfig>;
  2962. private loadModuleFactoryOrRoutes;
  2963. static ɵfac: i0.ɵɵFactoryDeclaration<RouterConfigLoader, never>;
  2964. static ɵprov: i0.ɵɵInjectableDeclaration<RouterConfigLoader>;
  2965. }
  2966. /**
  2967. * Extra configuration options that can be used with the `withRouterConfig` function.
  2968. *
  2969. * @publicApi
  2970. */
  2971. export declare interface RouterConfigOptions {
  2972. /**
  2973. * Configures how the Router attempts to restore state when a navigation is cancelled.
  2974. *
  2975. * 'replace' - Always uses `location.replaceState` to set the browser state to the state of the
  2976. * router before the navigation started. This means that if the URL of the browser is updated
  2977. * _before_ the navigation is canceled, the Router will simply replace the item in history rather
  2978. * than trying to restore to the previous location in the session history. This happens most
  2979. * frequently with `urlUpdateStrategy: 'eager'` and navigations with the browser back/forward
  2980. * buttons.
  2981. *
  2982. * 'computed' - Will attempt to return to the same index in the session history that corresponds
  2983. * to the Angular route when the navigation gets cancelled. For example, if the browser back
  2984. * button is clicked and the navigation is cancelled, the Router will trigger a forward navigation
  2985. * and vice versa.
  2986. *
  2987. * Note: the 'computed' option is incompatible with any `UrlHandlingStrategy` which only
  2988. * handles a portion of the URL because the history restoration navigates to the previous place in
  2989. * the browser history rather than simply resetting a portion of the URL.
  2990. *
  2991. * The default value is `replace` when not set.
  2992. */
  2993. canceledNavigationResolution?: 'replace' | 'computed';
  2994. /**
  2995. * Configures the default for handling a navigation request to the current URL.
  2996. *
  2997. * If unset, the `Router` will use `'ignore'`.
  2998. *
  2999. * @see `OnSameUrlNavigation`
  3000. */
  3001. onSameUrlNavigation?: OnSameUrlNavigation;
  3002. /**
  3003. * Defines how the router merges parameters, data, and resolved data from parent to child
  3004. * routes. By default ('emptyOnly'), inherits parent parameters only for
  3005. * path-less or component-less routes.
  3006. *
  3007. * Set to 'always' to enable unconditional inheritance of parent parameters.
  3008. *
  3009. * Note that when dealing with matrix parameters, "parent" refers to the parent `Route`
  3010. * config which does not necessarily mean the "URL segment to the left". When the `Route` `path`
  3011. * contains multiple segments, the matrix parameters must appear on the last segment. For example,
  3012. * matrix parameters for `{path: 'a/b', component: MyComp}` should appear as `a/b;foo=bar` and not
  3013. * `a;foo=bar/b`.
  3014. *
  3015. */
  3016. paramsInheritanceStrategy?: 'emptyOnly' | 'always';
  3017. /**
  3018. * Defines when the router updates the browser URL. By default ('deferred'),
  3019. * update after successful navigation.
  3020. * Set to 'eager' if prefer to update the URL at the beginning of navigation.
  3021. * Updating the URL early allows you to handle a failure of navigation by
  3022. * showing an error message with the URL that failed.
  3023. */
  3024. urlUpdateStrategy?: 'deferred' | 'eager';
  3025. }
  3026. /**
  3027. * A type alias for providers returned by `withRouterConfig` for use with `provideRouter`.
  3028. *
  3029. * @see `withRouterConfig`
  3030. * @see `provideRouter`
  3031. *
  3032. * @publicApi
  3033. */
  3034. export declare type RouterConfigurationFeature = RouterFeature<RouterFeatureKind.RouterConfigurationFeature>;
  3035. /**
  3036. * @description
  3037. *
  3038. * Provides a way to customize when activated routes get reused.
  3039. *
  3040. * @publicApi
  3041. */
  3042. export declare abstract class RouteReuseStrategy {
  3043. /** Determines if this route (and its subtree) should be detached to be reused later */
  3044. abstract shouldDetach(route: ActivatedRouteSnapshot): boolean;
  3045. /**
  3046. * Stores the detached route.
  3047. *
  3048. * Storing a `null` value should erase the previously stored value.
  3049. */
  3050. abstract store(route: ActivatedRouteSnapshot, handle: DetachedRouteHandle | null): void;
  3051. /** Determines if this route (and its subtree) should be reattached */
  3052. abstract shouldAttach(route: ActivatedRouteSnapshot): boolean;
  3053. /** Retrieves the previously stored route */
  3054. abstract retrieve(route: ActivatedRouteSnapshot): DetachedRouteHandle | null;
  3055. /** Determines if a route should be reused */
  3056. abstract shouldReuseRoute(future: ActivatedRouteSnapshot, curr: ActivatedRouteSnapshot): boolean;
  3057. static ɵfac: i0.ɵɵFactoryDeclaration<RouteReuseStrategy, never>;
  3058. static ɵprov: i0.ɵɵInjectableDeclaration<RouteReuseStrategy>;
  3059. }
  3060. /**
  3061. * Base for events the router goes through, as opposed to events tied to a specific
  3062. * route. Fired one time for any given navigation.
  3063. *
  3064. * The following code shows how a class subscribes to router events.
  3065. *
  3066. * ```ts
  3067. * import {Event, RouterEvent, Router} from '@angular/router';
  3068. *
  3069. * class MyService {
  3070. * constructor(public router: Router) {
  3071. * router.events.pipe(
  3072. * filter((e: Event): e is RouterEvent => e instanceof RouterEvent)
  3073. * ).subscribe((e: RouterEvent) => {
  3074. * // Do something
  3075. * });
  3076. * }
  3077. * }
  3078. * ```
  3079. *
  3080. * @see `Event`
  3081. * @see [Router events summary](guide/router-reference#router-events)
  3082. * @publicApi
  3083. */
  3084. export declare class RouterEvent {
  3085. /** A unique ID that the router assigns to every router navigation. */
  3086. id: number;
  3087. /** The URL that is the destination for this navigation. */
  3088. url: string;
  3089. constructor(
  3090. /** A unique ID that the router assigns to every router navigation. */
  3091. id: number,
  3092. /** The URL that is the destination for this navigation. */
  3093. url: string);
  3094. }
  3095. /**
  3096. * Helper type to represent a Router feature.
  3097. *
  3098. * @publicApi
  3099. */
  3100. export declare interface RouterFeature<FeatureKind extends RouterFeatureKind> {
  3101. ɵkind: FeatureKind;
  3102. ɵproviders: Provider[];
  3103. }
  3104. /**
  3105. * The list of features as an enum to uniquely type each feature.
  3106. */
  3107. declare const enum RouterFeatureKind {
  3108. PreloadingFeature = 0,
  3109. DebugTracingFeature = 1,
  3110. EnabledBlockingInitialNavigationFeature = 2,
  3111. DisabledInitialNavigationFeature = 3,
  3112. InMemoryScrollingFeature = 4,
  3113. RouterConfigurationFeature = 5,
  3114. RouterHashLocationFeature = 6,
  3115. NavigationErrorHandlerFeature = 7,
  3116. ComponentInputBindingFeature = 8
  3117. }
  3118. /**
  3119. * A type alias that represents all Router features available for use with `provideRouter`.
  3120. * Features can be enabled by adding special functions to the `provideRouter` call.
  3121. * See documentation for each symbol to find corresponding function name. See also `provideRouter`
  3122. * documentation on how to use those functions.
  3123. *
  3124. * @see `provideRouter`
  3125. *
  3126. * @publicApi
  3127. */
  3128. export declare type RouterFeatures = PreloadingFeature | DebugTracingFeature | InitialNavigationFeature | InMemoryScrollingFeature | RouterConfigurationFeature | NavigationErrorHandlerFeature | ComponentInputBindingFeature;
  3129. /**
  3130. * A type alias for providers returned by `withHashLocation` for use with `provideRouter`.
  3131. *
  3132. * @see `withHashLocation`
  3133. * @see `provideRouter`
  3134. *
  3135. * @publicApi
  3136. */
  3137. export declare type RouterHashLocationFeature = RouterFeature<RouterFeatureKind.RouterHashLocationFeature>;
  3138. /**
  3139. * @description
  3140. *
  3141. * When applied to an element in a template, makes that element a link
  3142. * that initiates navigation to a route. Navigation opens one or more routed components
  3143. * in one or more `<router-outlet>` locations on the page.
  3144. *
  3145. * Given a route configuration `[{ path: 'user/:name', component: UserCmp }]`,
  3146. * the following creates a static link to the route:
  3147. * `<a routerLink="/user/bob">link to user component</a>`
  3148. *
  3149. * You can use dynamic values to generate the link.
  3150. * For a dynamic link, pass an array of path segments,
  3151. * followed by the params for each segment.
  3152. * For example, `['/team', teamId, 'user', userName, {details: true}]`
  3153. * generates a link to `/team/11/user/bob;details=true`.
  3154. *
  3155. * Multiple static segments can be merged into one term and combined with dynamic segments.
  3156. * For example, `['/team/11/user', userName, {details: true}]`
  3157. *
  3158. * The input that you provide to the link is treated as a delta to the current URL.
  3159. * For instance, suppose the current URL is `/user/(box//aux:team)`.
  3160. * The link `<a [routerLink]="['/user/jim']">Jim</a>` creates the URL
  3161. * `/user/(jim//aux:team)`.
  3162. * See {@link Router#createUrlTree createUrlTree} for more information.
  3163. *
  3164. * @usageNotes
  3165. *
  3166. * You can use absolute or relative paths in a link, set query parameters,
  3167. * control how parameters are handled, and keep a history of navigation states.
  3168. *
  3169. * ### Relative link paths
  3170. *
  3171. * The first segment name can be prepended with `/`, `./`, or `../`.
  3172. * * If the first segment begins with `/`, the router looks up the route from the root of the
  3173. * app.
  3174. * * If the first segment begins with `./`, or doesn't begin with a slash, the router
  3175. * looks in the children of the current activated route.
  3176. * * If the first segment begins with `../`, the router goes up one level in the route tree.
  3177. *
  3178. * ### Setting and handling query params and fragments
  3179. *
  3180. * The following link adds a query parameter and a fragment to the generated URL:
  3181. *
  3182. * ```
  3183. * <a [routerLink]="['/user/bob']" [queryParams]="{debug: true}" fragment="education">
  3184. * link to user component
  3185. * </a>
  3186. * ```
  3187. * By default, the directive constructs the new URL using the given query parameters.
  3188. * The example generates the link: `/user/bob?debug=true#education`.
  3189. *
  3190. * You can instruct the directive to handle query parameters differently
  3191. * by specifying the `queryParamsHandling` option in the link.
  3192. * Allowed values are:
  3193. *
  3194. * - `'merge'`: Merge the given `queryParams` into the current query params.
  3195. * - `'preserve'`: Preserve the current query params.
  3196. *
  3197. * For example:
  3198. *
  3199. * ```
  3200. * <a [routerLink]="['/user/bob']" [queryParams]="{debug: true}" queryParamsHandling="merge">
  3201. * link to user component
  3202. * </a>
  3203. * ```
  3204. *
  3205. * See {@link UrlCreationOptions.queryParamsHandling UrlCreationOptions#queryParamsHandling}.
  3206. *
  3207. * ### Preserving navigation history
  3208. *
  3209. * You can provide a `state` value to be persisted to the browser's
  3210. * [`History.state` property](https://developer.mozilla.org/en-US/docs/Web/API/History#Properties).
  3211. * For example:
  3212. *
  3213. * ```
  3214. * <a [routerLink]="['/user/bob']" [state]="{tracingId: 123}">
  3215. * link to user component
  3216. * </a>
  3217. * ```
  3218. *
  3219. * Use {@link Router.getCurrentNavigation() Router#getCurrentNavigation} to retrieve a saved
  3220. * navigation-state value. For example, to capture the `tracingId` during the `NavigationStart`
  3221. * event:
  3222. *
  3223. * ```
  3224. * // Get NavigationStart events
  3225. * router.events.pipe(filter(e => e instanceof NavigationStart)).subscribe(e => {
  3226. * const navigation = router.getCurrentNavigation();
  3227. * tracingService.trace({id: navigation.extras.state.tracingId});
  3228. * });
  3229. * ```
  3230. *
  3231. * @ngModule RouterModule
  3232. *
  3233. * @publicApi
  3234. */
  3235. declare class RouterLink implements OnChanges, OnDestroy {
  3236. private router;
  3237. private route;
  3238. private readonly tabIndexAttribute;
  3239. private readonly renderer;
  3240. private readonly el;
  3241. private locationStrategy?;
  3242. private _preserveFragment;
  3243. private _skipLocationChange;
  3244. private _replaceUrl;
  3245. /**
  3246. * Represents an `href` attribute value applied to a host element,
  3247. * when a host element is `<a>`. For other tags, the value is `null`.
  3248. */
  3249. href: string | null;
  3250. /**
  3251. * Represents the `target` attribute on a host element.
  3252. * This is only used when the host element is an `<a>` tag.
  3253. */
  3254. target?: string;
  3255. /**
  3256. * Passed to {@link Router#createUrlTree Router#createUrlTree} as part of the
  3257. * `UrlCreationOptions`.
  3258. * @see {@link UrlCreationOptions#queryParams UrlCreationOptions#queryParams}
  3259. * @see {@link Router#createUrlTree Router#createUrlTree}
  3260. */
  3261. queryParams?: Params | null;
  3262. /**
  3263. * Passed to {@link Router#createUrlTree Router#createUrlTree} as part of the
  3264. * `UrlCreationOptions`.
  3265. * @see {@link UrlCreationOptions#fragment UrlCreationOptions#fragment}
  3266. * @see {@link Router#createUrlTree Router#createUrlTree}
  3267. */
  3268. fragment?: string;
  3269. /**
  3270. * Passed to {@link Router#createUrlTree Router#createUrlTree} as part of the
  3271. * `UrlCreationOptions`.
  3272. * @see {@link UrlCreationOptions#queryParamsHandling UrlCreationOptions#queryParamsHandling}
  3273. * @see {@link Router#createUrlTree Router#createUrlTree}
  3274. */
  3275. queryParamsHandling?: QueryParamsHandling | null;
  3276. /**
  3277. * Passed to {@link Router#navigateByUrl Router#navigateByUrl} as part of the
  3278. * `NavigationBehaviorOptions`.
  3279. * @see {@link NavigationBehaviorOptions#state NavigationBehaviorOptions#state}
  3280. * @see {@link Router#navigateByUrl Router#navigateByUrl}
  3281. */
  3282. state?: {
  3283. [k: string]: any;
  3284. };
  3285. /**
  3286. * Passed to {@link Router#createUrlTree Router#createUrlTree} as part of the
  3287. * `UrlCreationOptions`.
  3288. * Specify a value here when you do not want to use the default value
  3289. * for `routerLink`, which is the current activated route.
  3290. * Note that a value of `undefined` here will use the `routerLink` default.
  3291. * @see {@link UrlCreationOptions#relativeTo UrlCreationOptions#relativeTo}
  3292. * @see {@link Router#createUrlTree Router#createUrlTree}
  3293. */
  3294. relativeTo?: ActivatedRoute | null;
  3295. private commands;
  3296. /** Whether a host element is an `<a>` tag. */
  3297. private isAnchorElement;
  3298. private subscription?;
  3299. constructor(router: Router, route: ActivatedRoute, tabIndexAttribute: string | null | undefined, renderer: Renderer2, el: ElementRef, locationStrategy?: LocationStrategy | undefined);
  3300. /**
  3301. * Passed to {@link Router#createUrlTree Router#createUrlTree} as part of the
  3302. * `UrlCreationOptions`.
  3303. * @see {@link UrlCreationOptions#preserveFragment UrlCreationOptions#preserveFragment}
  3304. * @see {@link Router#createUrlTree Router#createUrlTree}
  3305. */
  3306. set preserveFragment(preserveFragment: boolean | string | null | undefined);
  3307. get preserveFragment(): boolean;
  3308. /**
  3309. * Passed to {@link Router#navigateByUrl Router#navigateByUrl} as part of the
  3310. * `NavigationBehaviorOptions`.
  3311. * @see {@link NavigationBehaviorOptions#skipLocationChange NavigationBehaviorOptions#skipLocationChange}
  3312. * @see {@link Router#navigateByUrl Router#navigateByUrl}
  3313. */
  3314. set skipLocationChange(skipLocationChange: boolean | string | null | undefined);
  3315. get skipLocationChange(): boolean;
  3316. /**
  3317. * Passed to {@link Router#navigateByUrl Router#navigateByUrl} as part of the
  3318. * `NavigationBehaviorOptions`.
  3319. * @see {@link NavigationBehaviorOptions#replaceUrl NavigationBehaviorOptions#replaceUrl}
  3320. * @see {@link Router#navigateByUrl Router#navigateByUrl}
  3321. */
  3322. set replaceUrl(replaceUrl: boolean | string | null | undefined);
  3323. get replaceUrl(): boolean;
  3324. /**
  3325. * Modifies the tab index if there was not a tabindex attribute on the element during
  3326. * instantiation.
  3327. */
  3328. private setTabIndexIfNotOnNativeEl;
  3329. /** @nodoc */
  3330. ngOnChanges(changes: SimpleChanges): void;
  3331. /**
  3332. * Commands to pass to {@link Router#createUrlTree Router#createUrlTree}.
  3333. * - **array**: commands to pass to {@link Router#createUrlTree Router#createUrlTree}.
  3334. * - **string**: shorthand for array of commands with just the string, i.e. `['/route']`
  3335. * - **null|undefined**: effectively disables the `routerLink`
  3336. * @see {@link Router#createUrlTree Router#createUrlTree}
  3337. */
  3338. set routerLink(commands: any[] | string | null | undefined);
  3339. /** @nodoc */
  3340. onClick(button: number, ctrlKey: boolean, shiftKey: boolean, altKey: boolean, metaKey: boolean): boolean;
  3341. /** @nodoc */
  3342. ngOnDestroy(): any;
  3343. private updateHref;
  3344. private applyAttributeValue;
  3345. get urlTree(): UrlTree | null;
  3346. static ɵfac: i0.ɵɵFactoryDeclaration<RouterLink, [null, null, { attribute: "tabindex"; }, null, null, null]>;
  3347. static ɵdir: i0.ɵɵDirectiveDeclaration<RouterLink, "[routerLink]", never, { "target": { "alias": "target"; "required": false; }; "queryParams": { "alias": "queryParams"; "required": false; }; "fragment": { "alias": "fragment"; "required": false; }; "queryParamsHandling": { "alias": "queryParamsHandling"; "required": false; }; "state": { "alias": "state"; "required": false; }; "relativeTo": { "alias": "relativeTo"; "required": false; }; "preserveFragment": { "alias": "preserveFragment"; "required": false; }; "skipLocationChange": { "alias": "skipLocationChange"; "required": false; }; "replaceUrl": { "alias": "replaceUrl"; "required": false; }; "routerLink": { "alias": "routerLink"; "required": false; }; }, {}, never, never, true, never>;
  3348. }
  3349. export { RouterLink }
  3350. export { RouterLink as RouterLinkWithHref }
  3351. /**
  3352. *
  3353. * @description
  3354. *
  3355. * Tracks whether the linked route of an element is currently active, and allows you
  3356. * to specify one or more CSS classes to add to the element when the linked route
  3357. * is active.
  3358. *
  3359. * Use this directive to create a visual distinction for elements associated with an active route.
  3360. * For example, the following code highlights the word "Bob" when the router
  3361. * activates the associated route:
  3362. *
  3363. * ```
  3364. * <a routerLink="/user/bob" routerLinkActive="active-link">Bob</a>
  3365. * ```
  3366. *
  3367. * Whenever the URL is either '/user' or '/user/bob', the "active-link" class is
  3368. * added to the anchor tag. If the URL changes, the class is removed.
  3369. *
  3370. * You can set more than one class using a space-separated string or an array.
  3371. * For example:
  3372. *
  3373. * ```
  3374. * <a routerLink="/user/bob" routerLinkActive="class1 class2">Bob</a>
  3375. * <a routerLink="/user/bob" [routerLinkActive]="['class1', 'class2']">Bob</a>
  3376. * ```
  3377. *
  3378. * To add the classes only when the URL matches the link exactly, add the option `exact: true`:
  3379. *
  3380. * ```
  3381. * <a routerLink="/user/bob" routerLinkActive="active-link" [routerLinkActiveOptions]="{exact:
  3382. * true}">Bob</a>
  3383. * ```
  3384. *
  3385. * To directly check the `isActive` status of the link, assign the `RouterLinkActive`
  3386. * instance to a template variable.
  3387. * For example, the following checks the status without assigning any CSS classes:
  3388. *
  3389. * ```
  3390. * <a routerLink="/user/bob" routerLinkActive #rla="routerLinkActive">
  3391. * Bob {{ rla.isActive ? '(already open)' : ''}}
  3392. * </a>
  3393. * ```
  3394. *
  3395. * You can apply the `RouterLinkActive` directive to an ancestor of linked elements.
  3396. * For example, the following sets the active-link class on the `<div>` parent tag
  3397. * when the URL is either '/user/jim' or '/user/bob'.
  3398. *
  3399. * ```
  3400. * <div routerLinkActive="active-link" [routerLinkActiveOptions]="{exact: true}">
  3401. * <a routerLink="/user/jim">Jim</a>
  3402. * <a routerLink="/user/bob">Bob</a>
  3403. * </div>
  3404. * ```
  3405. *
  3406. * The `RouterLinkActive` directive can also be used to set the aria-current attribute
  3407. * to provide an alternative distinction for active elements to visually impaired users.
  3408. *
  3409. * For example, the following code adds the 'active' class to the Home Page link when it is
  3410. * indeed active and in such case also sets its aria-current attribute to 'page':
  3411. *
  3412. * ```
  3413. * <a routerLink="/" routerLinkActive="active" ariaCurrentWhenActive="page">Home Page</a>
  3414. * ```
  3415. *
  3416. * @ngModule RouterModule
  3417. *
  3418. * @publicApi
  3419. */
  3420. export declare class RouterLinkActive implements OnChanges, OnDestroy, AfterContentInit {
  3421. private router;
  3422. private element;
  3423. private renderer;
  3424. private readonly cdr;
  3425. private link?;
  3426. links: QueryList<RouterLink>;
  3427. private classes;
  3428. private routerEventsSubscription;
  3429. private linkInputChangesSubscription?;
  3430. private _isActive;
  3431. get isActive(): boolean;
  3432. /**
  3433. * Options to configure how to determine if the router link is active.
  3434. *
  3435. * These options are passed to the `Router.isActive()` function.
  3436. *
  3437. * @see Router.isActive
  3438. */
  3439. routerLinkActiveOptions: {
  3440. exact: boolean;
  3441. } | IsActiveMatchOptions;
  3442. /**
  3443. * Aria-current attribute to apply when the router link is active.
  3444. *
  3445. * Possible values: `'page'` | `'step'` | `'location'` | `'date'` | `'time'` | `true` | `false`.
  3446. *
  3447. * @see {@link https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-current}
  3448. */
  3449. ariaCurrentWhenActive?: 'page' | 'step' | 'location' | 'date' | 'time' | true | false;
  3450. /**
  3451. *
  3452. * You can use the output `isActiveChange` to get notified each time the link becomes
  3453. * active or inactive.
  3454. *
  3455. * Emits:
  3456. * true -> Route is active
  3457. * false -> Route is inactive
  3458. *
  3459. * ```
  3460. * <a
  3461. * routerLink="/user/bob"
  3462. * routerLinkActive="active-link"
  3463. * (isActiveChange)="this.onRouterLinkActive($event)">Bob</a>
  3464. * ```
  3465. */
  3466. readonly isActiveChange: EventEmitter<boolean>;
  3467. constructor(router: Router, element: ElementRef, renderer: Renderer2, cdr: ChangeDetectorRef, link?: RouterLink | undefined);
  3468. /** @nodoc */
  3469. ngAfterContentInit(): void;
  3470. private subscribeToEachLinkOnChanges;
  3471. set routerLinkActive(data: string[] | string);
  3472. /** @nodoc */
  3473. ngOnChanges(changes: SimpleChanges): void;
  3474. /** @nodoc */
  3475. ngOnDestroy(): void;
  3476. private update;
  3477. private isLinkActive;
  3478. private hasActiveLinks;
  3479. static ɵfac: i0.ɵɵFactoryDeclaration<RouterLinkActive, [null, null, null, null, { optional: true; }]>;
  3480. static ɵdir: i0.ɵɵDirectiveDeclaration<RouterLinkActive, "[routerLinkActive]", ["routerLinkActive"], { "routerLinkActiveOptions": { "alias": "routerLinkActiveOptions"; "required": false; }; "ariaCurrentWhenActive": { "alias": "ariaCurrentWhenActive"; "required": false; }; "routerLinkActive": { "alias": "routerLinkActive"; "required": false; }; }, { "isActiveChange": "isActiveChange"; }, ["links"], never, true, never>;
  3481. }
  3482. /**
  3483. * @description
  3484. *
  3485. * Adds directives and providers for in-app navigation among views defined in an application.
  3486. * Use the Angular `Router` service to declaratively specify application states and manage state
  3487. * transitions.
  3488. *
  3489. * You can import this NgModule multiple times, once for each lazy-loaded bundle.
  3490. * However, only one `Router` service can be active.
  3491. * To ensure this, there are two ways to register routes when importing this module:
  3492. *
  3493. * * The `forRoot()` method creates an `NgModule` that contains all the directives, the given
  3494. * routes, and the `Router` service itself.
  3495. * * The `forChild()` method creates an `NgModule` that contains all the directives and the given
  3496. * routes, but does not include the `Router` service.
  3497. *
  3498. * @see [Routing and Navigation guide](guide/router) for an
  3499. * overview of how the `Router` service should be used.
  3500. *
  3501. * @publicApi
  3502. */
  3503. export declare class RouterModule {
  3504. constructor(guard: any);
  3505. /**
  3506. * Creates and configures a module with all the router providers and directives.
  3507. * Optionally sets up an application listener to perform an initial navigation.
  3508. *
  3509. * When registering the NgModule at the root, import as follows:
  3510. *
  3511. * ```
  3512. * @NgModule({
  3513. * imports: [RouterModule.forRoot(ROUTES)]
  3514. * })
  3515. * class MyNgModule {}
  3516. * ```
  3517. *
  3518. * @param routes An array of `Route` objects that define the navigation paths for the application.
  3519. * @param config An `ExtraOptions` configuration object that controls how navigation is performed.
  3520. * @return The new `NgModule`.
  3521. *
  3522. */
  3523. static forRoot(routes: Routes, config?: ExtraOptions): ModuleWithProviders<RouterModule>;
  3524. /**
  3525. * Creates a module with all the router directives and a provider registering routes,
  3526. * without creating a new Router service.
  3527. * When registering for submodules and lazy-loaded submodules, create the NgModule as follows:
  3528. *
  3529. * ```
  3530. * @NgModule({
  3531. * imports: [RouterModule.forChild(ROUTES)]
  3532. * })
  3533. * class MyNgModule {}
  3534. * ```
  3535. *
  3536. * @param routes An array of `Route` objects that define the navigation paths for the submodule.
  3537. * @return The new NgModule.
  3538. *
  3539. */
  3540. static forChild(routes: Routes): ModuleWithProviders<RouterModule>;
  3541. static ɵfac: i0.ɵɵFactoryDeclaration<RouterModule, [{ optional: true; }]>;
  3542. static ɵmod: i0.ɵɵNgModuleDeclaration<RouterModule, never, [typeof i1.RouterOutlet, typeof i2.RouterLink, typeof i3.RouterLinkActive, typeof i4.ɵEmptyOutletComponent], [typeof i1.RouterOutlet, typeof i2.RouterLink, typeof i3.RouterLinkActive, typeof i4.ɵEmptyOutletComponent]>;
  3543. static ɵinj: i0.ɵɵInjectorDeclaration<RouterModule>;
  3544. }
  3545. /**
  3546. * @description
  3547. *
  3548. * Acts as a placeholder that Angular dynamically fills based on the current router state.
  3549. *
  3550. * Each outlet can have a unique name, determined by the optional `name` attribute.
  3551. * The name cannot be set or changed dynamically. If not set, default value is "primary".
  3552. *
  3553. * ```
  3554. * <router-outlet></router-outlet>
  3555. * <router-outlet name='left'></router-outlet>
  3556. * <router-outlet name='right'></router-outlet>
  3557. * ```
  3558. *
  3559. * Named outlets can be the targets of secondary routes.
  3560. * The `Route` object for a secondary route has an `outlet` property to identify the target outlet:
  3561. *
  3562. * `{path: <base-path>, component: <component>, outlet: <target_outlet_name>}`
  3563. *
  3564. * Using named outlets and secondary routes, you can target multiple outlets in
  3565. * the same `RouterLink` directive.
  3566. *
  3567. * The router keeps track of separate branches in a navigation tree for each named outlet and
  3568. * generates a representation of that tree in the URL.
  3569. * The URL for a secondary route uses the following syntax to specify both the primary and secondary
  3570. * routes at the same time:
  3571. *
  3572. * `http://base-path/primary-route-path(outlet-name:route-path)`
  3573. *
  3574. * A router outlet emits an activate event when a new component is instantiated,
  3575. * deactivate event when a component is destroyed.
  3576. * An attached event emits when the `RouteReuseStrategy` instructs the outlet to reattach the
  3577. * subtree, and the detached event emits when the `RouteReuseStrategy` instructs the outlet to
  3578. * detach the subtree.
  3579. *
  3580. * ```
  3581. * <router-outlet
  3582. * (activate)='onActivate($event)'
  3583. * (deactivate)='onDeactivate($event)'
  3584. * (attach)='onAttach($event)'
  3585. * (detach)='onDetach($event)'></router-outlet>
  3586. * ```
  3587. *
  3588. * @see [Routing tutorial](guide/router-tutorial-toh#named-outlets "Example of a named
  3589. * outlet and secondary route configuration").
  3590. * @see `RouterLink`
  3591. * @see `Route`
  3592. * @ngModule RouterModule
  3593. *
  3594. * @publicApi
  3595. */
  3596. export declare class RouterOutlet implements OnDestroy, OnInit, RouterOutletContract {
  3597. private activated;
  3598. private _activatedRoute;
  3599. /**
  3600. * The name of the outlet
  3601. *
  3602. * @see [named outlets](guide/router-tutorial-toh#displaying-multiple-routes-in-named-outlets)
  3603. */
  3604. name: string;
  3605. activateEvents: EventEmitter<any>;
  3606. deactivateEvents: EventEmitter<any>;
  3607. /**
  3608. * Emits an attached component instance when the `RouteReuseStrategy` instructs to re-attach a
  3609. * previously detached subtree.
  3610. **/
  3611. attachEvents: EventEmitter<unknown>;
  3612. /**
  3613. * Emits a detached component instance when the `RouteReuseStrategy` instructs to detach the
  3614. * subtree.
  3615. */
  3616. detachEvents: EventEmitter<unknown>;
  3617. private parentContexts;
  3618. private location;
  3619. private changeDetector;
  3620. private environmentInjector;
  3621. private inputBinder;
  3622. /** @nodoc */
  3623. readonly supportsBindingToComponentInputs = true;
  3624. /** @nodoc */
  3625. ngOnChanges(changes: SimpleChanges): void;
  3626. /** @nodoc */
  3627. ngOnDestroy(): void;
  3628. private isTrackedInParentContexts;
  3629. /** @nodoc */
  3630. ngOnInit(): void;
  3631. private initializeOutletWithName;
  3632. get isActivated(): boolean;
  3633. /**
  3634. * @returns The currently activated component instance.
  3635. * @throws An error if the outlet is not activated.
  3636. */
  3637. get component(): Object;
  3638. get activatedRoute(): ActivatedRoute;
  3639. get activatedRouteData(): Data;
  3640. /**
  3641. * Called when the `RouteReuseStrategy` instructs to detach the subtree
  3642. */
  3643. detach(): ComponentRef<any>;
  3644. /**
  3645. * Called when the `RouteReuseStrategy` instructs to re-attach a previously detached subtree
  3646. */
  3647. attach(ref: ComponentRef<any>, activatedRoute: ActivatedRoute): void;
  3648. deactivate(): void;
  3649. activateWith(activatedRoute: ActivatedRoute, environmentInjector?: EnvironmentInjector | null): void;
  3650. static ɵfac: i0.ɵɵFactoryDeclaration<RouterOutlet, never>;
  3651. static ɵdir: i0.ɵɵDirectiveDeclaration<RouterOutlet, "router-outlet", ["outlet"], { "name": { "alias": "name"; "required": false; }; }, { "activateEvents": "activate"; "deactivateEvents": "deactivate"; "attachEvents": "attach"; "detachEvents": "detach"; }, never, never, true, never>;
  3652. }
  3653. /**
  3654. * An interface that defines the contract for developing a component outlet for the `Router`.
  3655. *
  3656. * An outlet acts as a placeholder that Angular dynamically fills based on the current router state.
  3657. *
  3658. * A router outlet should register itself with the `Router` via
  3659. * `ChildrenOutletContexts#onChildOutletCreated` and unregister with
  3660. * `ChildrenOutletContexts#onChildOutletDestroyed`. When the `Router` identifies a matched `Route`,
  3661. * it looks for a registered outlet in the `ChildrenOutletContexts` and activates it.
  3662. *
  3663. * @see `ChildrenOutletContexts`
  3664. * @publicApi
  3665. */
  3666. export declare interface RouterOutletContract {
  3667. /**
  3668. * Whether the given outlet is activated.
  3669. *
  3670. * An outlet is considered "activated" if it has an active component.
  3671. */
  3672. isActivated: boolean;
  3673. /** The instance of the activated component or `null` if the outlet is not activated. */
  3674. component: Object | null;
  3675. /**
  3676. * The `Data` of the `ActivatedRoute` snapshot.
  3677. */
  3678. activatedRouteData: Data;
  3679. /**
  3680. * The `ActivatedRoute` for the outlet or `null` if the outlet is not activated.
  3681. */
  3682. activatedRoute: ActivatedRoute | null;
  3683. /**
  3684. * Called by the `Router` when the outlet should activate (create a component).
  3685. */
  3686. activateWith(activatedRoute: ActivatedRoute, environmentInjector: EnvironmentInjector | null): void;
  3687. /**
  3688. * A request to destroy the currently activated component.
  3689. *
  3690. * When a `RouteReuseStrategy` indicates that an `ActivatedRoute` should be removed but stored for
  3691. * later re-use rather than destroyed, the `Router` will call `detach` instead.
  3692. */
  3693. deactivate(): void;
  3694. /**
  3695. * Called when the `RouteReuseStrategy` instructs to detach the subtree.
  3696. *
  3697. * This is similar to `deactivate`, but the activated component should _not_ be destroyed.
  3698. * Instead, it is returned so that it can be reattached later via the `attach` method.
  3699. */
  3700. detach(): ComponentRef<unknown>;
  3701. /**
  3702. * Called when the `RouteReuseStrategy` instructs to re-attach a previously detached subtree.
  3703. */
  3704. attach(ref: ComponentRef<unknown>, activatedRoute: ActivatedRoute): void;
  3705. /**
  3706. * Emits an activate event when a new component is instantiated
  3707. **/
  3708. activateEvents?: EventEmitter<unknown>;
  3709. /**
  3710. * Emits a deactivate event when a component is destroyed.
  3711. */
  3712. deactivateEvents?: EventEmitter<unknown>;
  3713. /**
  3714. * Emits an attached component instance when the `RouteReuseStrategy` instructs to re-attach a
  3715. * previously detached subtree.
  3716. **/
  3717. attachEvents?: EventEmitter<unknown>;
  3718. /**
  3719. * Emits a detached component instance when the `RouteReuseStrategy` instructs to detach the
  3720. * subtree.
  3721. */
  3722. detachEvents?: EventEmitter<unknown>;
  3723. /**
  3724. * Used to indicate that the outlet is able to bind data from the `Router` to the outlet
  3725. * component's inputs.
  3726. *
  3727. * When this is `undefined` or `false` and the developer has opted in to the
  3728. * feature using `withComponentInputBinding`, a warning will be logged in dev mode if this outlet
  3729. * is used in the application.
  3730. */
  3731. readonly supportsBindingToComponentInputs?: true;
  3732. }
  3733. /**
  3734. * The preloader optimistically loads all router configurations to
  3735. * make navigations into lazily-loaded sections of the application faster.
  3736. *
  3737. * The preloader runs in the background. When the router bootstraps, the preloader
  3738. * starts listening to all navigation events. After every such event, the preloader
  3739. * will check if any configurations can be loaded lazily.
  3740. *
  3741. * If a route is protected by `canLoad` guards, the preloaded will not load it.
  3742. *
  3743. * @publicApi
  3744. */
  3745. export declare class RouterPreloader implements OnDestroy {
  3746. private router;
  3747. private injector;
  3748. private preloadingStrategy;
  3749. private loader;
  3750. private subscription?;
  3751. constructor(router: Router, compiler: Compiler, injector: EnvironmentInjector, preloadingStrategy: PreloadingStrategy, loader: RouterConfigLoader);
  3752. setUpPreloading(): void;
  3753. preload(): Observable<any>;
  3754. /** @nodoc */
  3755. ngOnDestroy(): void;
  3756. private processRoutes;
  3757. private preloadConfig;
  3758. static ɵfac: i0.ɵɵFactoryDeclaration<RouterPreloader, never>;
  3759. static ɵprov: i0.ɵɵInjectableDeclaration<RouterPreloader>;
  3760. }
  3761. /**
  3762. * Represents the state of the router as a tree of activated routes.
  3763. *
  3764. * @usageNotes
  3765. *
  3766. * Every node in the route tree is an `ActivatedRoute` instance
  3767. * that knows about the "consumed" URL segments, the extracted parameters,
  3768. * and the resolved data.
  3769. * Use the `ActivatedRoute` properties to traverse the tree from any node.
  3770. *
  3771. * The following fragment shows how a component gets the root node
  3772. * of the current state to establish its own route tree:
  3773. *
  3774. * ```
  3775. * @Component({templateUrl:'template.html'})
  3776. * class MyComponent {
  3777. * constructor(router: Router) {
  3778. * const state: RouterState = router.routerState;
  3779. * const root: ActivatedRoute = state.root;
  3780. * const child = root.firstChild;
  3781. * const id: Observable<string> = child.params.map(p => p.id);
  3782. * //...
  3783. * }
  3784. * }
  3785. * ```
  3786. *
  3787. * @see `ActivatedRoute`
  3788. * @see [Getting route information](guide/router#getting-route-information)
  3789. *
  3790. * @publicApi
  3791. */
  3792. export declare class RouterState extends Tree<ActivatedRoute> {
  3793. /** The current snapshot of the router state */
  3794. snapshot: RouterStateSnapshot;
  3795. toString(): string;
  3796. }
  3797. /**
  3798. * @description
  3799. *
  3800. * Represents the state of the router at a moment in time.
  3801. *
  3802. * This is a tree of activated route snapshots. Every node in this tree knows about
  3803. * the "consumed" URL segments, the extracted parameters, and the resolved data.
  3804. *
  3805. * The following example shows how a component is initialized with information
  3806. * from the snapshot of the root node's state at the time of creation.
  3807. *
  3808. * ```
  3809. * @Component({templateUrl:'template.html'})
  3810. * class MyComponent {
  3811. * constructor(router: Router) {
  3812. * const state: RouterState = router.routerState;
  3813. * const snapshot: RouterStateSnapshot = state.snapshot;
  3814. * const root: ActivatedRouteSnapshot = snapshot.root;
  3815. * const child = root.firstChild;
  3816. * const id: Observable<string> = child.params.map(p => p.id);
  3817. * //...
  3818. * }
  3819. * }
  3820. * ```
  3821. *
  3822. * @publicApi
  3823. */
  3824. export declare class RouterStateSnapshot extends Tree<ActivatedRouteSnapshot> {
  3825. /** The url from which this snapshot was created */
  3826. url: string;
  3827. toString(): string;
  3828. }
  3829. /**
  3830. * The [DI token](guide/glossary/#di-token) for a router configuration.
  3831. *
  3832. * `ROUTES` is a low level API for router configuration via dependency injection.
  3833. *
  3834. * We recommend that in almost all cases to use higher level APIs such as `RouterModule.forRoot()`,
  3835. * `provideRouter`, or `Router.resetConfig()`.
  3836. *
  3837. * @publicApi
  3838. */
  3839. export declare const ROUTES: InjectionToken<Route[][]>;
  3840. /**
  3841. * Represents a route configuration for the Router service.
  3842. * An array of `Route` objects, used in `Router.config` and for nested route configurations
  3843. * in `Route.children`.
  3844. *
  3845. * @see `Route`
  3846. * @see `Router`
  3847. * @see [Router configuration guide](guide/router-reference#configuration)
  3848. * @publicApi
  3849. */
  3850. export declare type Routes = Route[];
  3851. /**
  3852. * An event triggered when routes are recognized.
  3853. *
  3854. * @publicApi
  3855. */
  3856. export declare class RoutesRecognized extends RouterEvent {
  3857. /** @docsNotRequired */
  3858. urlAfterRedirects: string;
  3859. /** @docsNotRequired */
  3860. state: RouterStateSnapshot;
  3861. readonly type = EventType.RoutesRecognized;
  3862. constructor(
  3863. /** @docsNotRequired */
  3864. id: number,
  3865. /** @docsNotRequired */
  3866. url: string,
  3867. /** @docsNotRequired */
  3868. urlAfterRedirects: string,
  3869. /** @docsNotRequired */
  3870. state: RouterStateSnapshot);
  3871. /** @docsNotRequired */
  3872. toString(): string;
  3873. }
  3874. /**
  3875. * A policy for when to run guards and resolvers on a route.
  3876. *
  3877. * Guards and/or resolvers will always run when a route is activated or deactivated. When a route is
  3878. * unchanged, the default behavior is the same as `paramsChange`.
  3879. *
  3880. * `paramsChange` : Rerun the guards and resolvers when path or
  3881. * path param changes. This does not include query parameters. This option is the default.
  3882. * - `always` : Run on every execution.
  3883. * - `pathParamsChange` : Rerun guards and resolvers when the path params
  3884. * change. This does not compare matrix or query parameters.
  3885. * - `paramsOrQueryParamsChange` : Run when path, matrix, or query parameters change.
  3886. * - `pathParamsOrQueryParamsChange` : Rerun guards and resolvers when the path params
  3887. * change or query params have changed. This does not include matrix parameters.
  3888. *
  3889. * @see [Route.runGuardsAndResolvers](api/router/Route#runGuardsAndResolvers)
  3890. * @publicApi
  3891. */
  3892. export declare type RunGuardsAndResolvers = 'pathParamsChange' | 'pathParamsOrQueryParamsChange' | 'paramsChange' | 'paramsOrQueryParamsChange' | 'always' | ((from: ActivatedRouteSnapshot, to: ActivatedRouteSnapshot) => boolean);
  3893. /**
  3894. * An event triggered by scrolling.
  3895. *
  3896. * @publicApi
  3897. */
  3898. export declare class Scroll {
  3899. /** @docsNotRequired */
  3900. readonly routerEvent: NavigationEnd | NavigationSkipped;
  3901. /** @docsNotRequired */
  3902. readonly position: [number, number] | null;
  3903. /** @docsNotRequired */
  3904. readonly anchor: string | null;
  3905. readonly type = EventType.Scroll;
  3906. constructor(
  3907. /** @docsNotRequired */
  3908. routerEvent: NavigationEnd | NavigationSkipped,
  3909. /** @docsNotRequired */
  3910. position: [number, number] | null,
  3911. /** @docsNotRequired */
  3912. anchor: string | null);
  3913. toString(): string;
  3914. }
  3915. /**
  3916. * Provides a strategy for setting the page title after a router navigation.
  3917. *
  3918. * The built-in implementation traverses the router state snapshot and finds the deepest primary
  3919. * outlet with `title` property. Given the `Routes` below, navigating to
  3920. * `/base/child(popup:aux)` would result in the document title being set to "child".
  3921. * ```
  3922. * [
  3923. * {path: 'base', title: 'base', children: [
  3924. * {path: 'child', title: 'child'},
  3925. * ],
  3926. * {path: 'aux', outlet: 'popup', title: 'popupTitle'}
  3927. * ]
  3928. * ```
  3929. *
  3930. * This class can be used as a base class for custom title strategies. That is, you can create your
  3931. * own class that extends the `TitleStrategy`. Note that in the above example, the `title`
  3932. * from the named outlet is never used. However, a custom strategy might be implemented to
  3933. * incorporate titles in named outlets.
  3934. *
  3935. * @publicApi
  3936. * @see [Page title guide](guide/router#setting-the-page-title)
  3937. */
  3938. export declare abstract class TitleStrategy {
  3939. /** Performs the application title update. */
  3940. abstract updateTitle(snapshot: RouterStateSnapshot): void;
  3941. /**
  3942. * @returns The `title` of the deepest primary route.
  3943. */
  3944. buildTitle(snapshot: RouterStateSnapshot): string | undefined;
  3945. /**
  3946. * Given an `ActivatedRouteSnapshot`, returns the final value of the
  3947. * `Route.title` property, which can either be a static string or a resolved value.
  3948. */
  3949. getResolvedTitleForRoute(snapshot: ActivatedRouteSnapshot): any;
  3950. static ɵfac: i0.ɵɵFactoryDeclaration<TitleStrategy, never>;
  3951. static ɵprov: i0.ɵɵInjectableDeclaration<TitleStrategy>;
  3952. }
  3953. declare class Tree<T> {
  3954. constructor(root: TreeNode<T>);
  3955. get root(): T;
  3956. }
  3957. declare class TreeNode<T> {
  3958. value: T;
  3959. children: TreeNode<T>[];
  3960. constructor(value: T, children: TreeNode<T>[]);
  3961. toString(): string;
  3962. }
  3963. /**
  3964. * @description
  3965. *
  3966. * Options that modify the `Router` URL.
  3967. * Supply an object containing any of these properties to a `Router` navigation function to
  3968. * control how the target URL should be constructed.
  3969. *
  3970. * @see [Router.navigate() method](api/router/Router#navigate)
  3971. * @see [Router.createUrlTree() method](api/router/Router#createurltree)
  3972. * @see [Routing and Navigation guide](guide/router)
  3973. *
  3974. * @publicApi
  3975. */
  3976. export declare interface UrlCreationOptions {
  3977. /**
  3978. * Specifies a root URI to use for relative navigation.
  3979. *
  3980. * For example, consider the following route configuration where the parent route
  3981. * has two children.
  3982. *
  3983. * ```
  3984. * [{
  3985. * path: 'parent',
  3986. * component: ParentComponent,
  3987. * children: [{
  3988. * path: 'list',
  3989. * component: ListComponent
  3990. * },{
  3991. * path: 'child',
  3992. * component: ChildComponent
  3993. * }]
  3994. * }]
  3995. * ```
  3996. *
  3997. * The following `go()` function navigates to the `list` route by
  3998. * interpreting the destination URI as relative to the activated `child` route
  3999. *
  4000. * ```
  4001. * @Component({...})
  4002. * class ChildComponent {
  4003. * constructor(private router: Router, private route: ActivatedRoute) {}
  4004. *
  4005. * go() {
  4006. * router.navigate(['../list'], { relativeTo: this.route });
  4007. * }
  4008. * }
  4009. * ```
  4010. *
  4011. * A value of `null` or `undefined` indicates that the navigation commands should be applied
  4012. * relative to the root.
  4013. */
  4014. relativeTo?: ActivatedRoute | null;
  4015. /**
  4016. * Sets query parameters to the URL.
  4017. *
  4018. * ```
  4019. * // Navigate to /results?page=1
  4020. * router.navigate(['/results'], { queryParams: { page: 1 } });
  4021. * ```
  4022. */
  4023. queryParams?: Params | null;
  4024. /**
  4025. * Sets the hash fragment for the URL.
  4026. *
  4027. * ```
  4028. * // Navigate to /results#top
  4029. * router.navigate(['/results'], { fragment: 'top' });
  4030. * ```
  4031. */
  4032. fragment?: string;
  4033. /**
  4034. * How to handle query parameters in the router link for the next navigation.
  4035. * One of:
  4036. * * `preserve` : Preserve current parameters.
  4037. * * `merge` : Merge new with current parameters.
  4038. *
  4039. * The "preserve" option discards any new query params:
  4040. * ```
  4041. * // from /view1?page=1 to/view2?page=1
  4042. * router.navigate(['/view2'], { queryParams: { page: 2 }, queryParamsHandling: "preserve"
  4043. * });
  4044. * ```
  4045. * The "merge" option appends new query params to the params from the current URL:
  4046. * ```
  4047. * // from /view1?page=1 to/view2?page=1&otherKey=2
  4048. * router.navigate(['/view2'], { queryParams: { otherKey: 2 }, queryParamsHandling: "merge"
  4049. * });
  4050. * ```
  4051. * In case of a key collision between current parameters and those in the `queryParams` object,
  4052. * the new value is used.
  4053. *
  4054. */
  4055. queryParamsHandling?: QueryParamsHandling | null;
  4056. /**
  4057. * When true, preserves the URL fragment for the next navigation
  4058. *
  4059. * ```
  4060. * // Preserve fragment from /results#top to /view#top
  4061. * router.navigate(['/view'], { preserveFragment: true });
  4062. * ```
  4063. */
  4064. preserveFragment?: boolean;
  4065. }
  4066. /**
  4067. * @description
  4068. *
  4069. * Provides a way to migrate AngularJS applications to Angular.
  4070. *
  4071. * @publicApi
  4072. */
  4073. export declare abstract class UrlHandlingStrategy {
  4074. /**
  4075. * Tells the router if this URL should be processed.
  4076. *
  4077. * When it returns true, the router will execute the regular navigation.
  4078. * When it returns false, the router will set the router state to an empty state.
  4079. * As a result, all the active components will be destroyed.
  4080. *
  4081. */
  4082. abstract shouldProcessUrl(url: UrlTree): boolean;
  4083. /**
  4084. * Extracts the part of the URL that should be handled by the router.
  4085. * The rest of the URL will remain untouched.
  4086. */
  4087. abstract extract(url: UrlTree): UrlTree;
  4088. /**
  4089. * Merges the URL fragment with the rest of the URL.
  4090. */
  4091. abstract merge(newUrlPart: UrlTree, rawUrl: UrlTree): UrlTree;
  4092. static ɵfac: i0.ɵɵFactoryDeclaration<UrlHandlingStrategy, never>;
  4093. static ɵprov: i0.ɵɵInjectableDeclaration<UrlHandlingStrategy>;
  4094. }
  4095. /**
  4096. * A function for matching a route against URLs. Implement a custom URL matcher
  4097. * for `Route.matcher` when a combination of `path` and `pathMatch`
  4098. * is not expressive enough. Cannot be used together with `path` and `pathMatch`.
  4099. *
  4100. * The function takes the following arguments and returns a `UrlMatchResult` object.
  4101. * * *segments* : An array of URL segments.
  4102. * * *group* : A segment group.
  4103. * * *route* : The route to match against.
  4104. *
  4105. * The following example implementation matches HTML files.
  4106. *
  4107. * ```
  4108. * export function htmlFiles(url: UrlSegment[]) {
  4109. * return url.length === 1 && url[0].path.endsWith('.html') ? ({consumed: url}) : null;
  4110. * }
  4111. *
  4112. * export const routes = [{ matcher: htmlFiles, component: AnyComponent }];
  4113. * ```
  4114. *
  4115. * @publicApi
  4116. */
  4117. export declare type UrlMatcher = (segments: UrlSegment[], group: UrlSegmentGroup, route: Route) => UrlMatchResult | null;
  4118. /**
  4119. * Represents the result of matching URLs with a custom matching function.
  4120. *
  4121. * * `consumed` is an array of the consumed URL segments.
  4122. * * `posParams` is a map of positional parameters.
  4123. *
  4124. * @see `UrlMatcher()`
  4125. * @publicApi
  4126. */
  4127. export declare type UrlMatchResult = {
  4128. consumed: UrlSegment[];
  4129. posParams?: {
  4130. [name: string]: UrlSegment;
  4131. };
  4132. };
  4133. /**
  4134. * @description
  4135. *
  4136. * Represents a single URL segment.
  4137. *
  4138. * A UrlSegment is a part of a URL between the two slashes. It contains a path and the matrix
  4139. * parameters associated with the segment.
  4140. *
  4141. * @usageNotes
  4142. * ### Example
  4143. *
  4144. * ```
  4145. * @Component({templateUrl:'template.html'})
  4146. * class MyComponent {
  4147. * constructor(router: Router) {
  4148. * const tree: UrlTree = router.parseUrl('/team;id=33');
  4149. * const g: UrlSegmentGroup = tree.root.children[PRIMARY_OUTLET];
  4150. * const s: UrlSegment[] = g.segments;
  4151. * s[0].path; // returns 'team'
  4152. * s[0].parameters; // returns {id: 33}
  4153. * }
  4154. * }
  4155. * ```
  4156. *
  4157. * @publicApi
  4158. */
  4159. export declare class UrlSegment {
  4160. /** The path part of a URL segment */
  4161. path: string;
  4162. /** The matrix parameters associated with a segment */
  4163. parameters: {
  4164. [name: string]: string;
  4165. };
  4166. constructor(
  4167. /** The path part of a URL segment */
  4168. path: string,
  4169. /** The matrix parameters associated with a segment */
  4170. parameters: {
  4171. [name: string]: string;
  4172. });
  4173. get parameterMap(): ParamMap;
  4174. /** @docsNotRequired */
  4175. toString(): string;
  4176. }
  4177. /**
  4178. * @description
  4179. *
  4180. * Represents the parsed URL segment group.
  4181. *
  4182. * See `UrlTree` for more information.
  4183. *
  4184. * @publicApi
  4185. */
  4186. export declare class UrlSegmentGroup {
  4187. /** The URL segments of this group. See `UrlSegment` for more information */
  4188. segments: UrlSegment[];
  4189. /** The list of children of this group */
  4190. children: {
  4191. [key: string]: UrlSegmentGroup;
  4192. };
  4193. /** The parent node in the url tree */
  4194. parent: UrlSegmentGroup | null;
  4195. constructor(
  4196. /** The URL segments of this group. See `UrlSegment` for more information */
  4197. segments: UrlSegment[],
  4198. /** The list of children of this group */
  4199. children: {
  4200. [key: string]: UrlSegmentGroup;
  4201. });
  4202. /** Whether the segment has child segments */
  4203. hasChildren(): boolean;
  4204. /** Number of child segments */
  4205. get numberOfChildren(): number;
  4206. /** @docsNotRequired */
  4207. toString(): string;
  4208. }
  4209. /**
  4210. * @description
  4211. *
  4212. * Serializes and deserializes a URL string into a URL tree.
  4213. *
  4214. * The url serialization strategy is customizable. You can
  4215. * make all URLs case insensitive by providing a custom UrlSerializer.
  4216. *
  4217. * See `DefaultUrlSerializer` for an example of a URL serializer.
  4218. *
  4219. * @publicApi
  4220. */
  4221. export declare abstract class UrlSerializer {
  4222. /** Parse a url into a `UrlTree` */
  4223. abstract parse(url: string): UrlTree;
  4224. /** Converts a `UrlTree` into a url */
  4225. abstract serialize(tree: UrlTree): string;
  4226. static ɵfac: i0.ɵɵFactoryDeclaration<UrlSerializer, never>;
  4227. static ɵprov: i0.ɵɵInjectableDeclaration<UrlSerializer>;
  4228. }
  4229. /**
  4230. * @description
  4231. *
  4232. * Represents the parsed URL.
  4233. *
  4234. * Since a router state is a tree, and the URL is nothing but a serialized state, the URL is a
  4235. * serialized tree.
  4236. * UrlTree is a data structure that provides a lot of affordances in dealing with URLs
  4237. *
  4238. * @usageNotes
  4239. * ### Example
  4240. *
  4241. * ```
  4242. * @Component({templateUrl:'template.html'})
  4243. * class MyComponent {
  4244. * constructor(router: Router) {
  4245. * const tree: UrlTree =
  4246. * router.parseUrl('/team/33/(user/victor//support:help)?debug=true#fragment');
  4247. * const f = tree.fragment; // return 'fragment'
  4248. * const q = tree.queryParams; // returns {debug: 'true'}
  4249. * const g: UrlSegmentGroup = tree.root.children[PRIMARY_OUTLET];
  4250. * const s: UrlSegment[] = g.segments; // returns 2 segments 'team' and '33'
  4251. * g.children[PRIMARY_OUTLET].segments; // returns 2 segments 'user' and 'victor'
  4252. * g.children['support'].segments; // return 1 segment 'help'
  4253. * }
  4254. * }
  4255. * ```
  4256. *
  4257. * @publicApi
  4258. */
  4259. export declare class UrlTree {
  4260. /** The root segment group of the URL tree */
  4261. root: UrlSegmentGroup;
  4262. /** The query params of the URL */
  4263. queryParams: Params;
  4264. /** The fragment of the URL */
  4265. fragment: string | null;
  4266. constructor(
  4267. /** The root segment group of the URL tree */
  4268. root?: UrlSegmentGroup,
  4269. /** The query params of the URL */
  4270. queryParams?: Params,
  4271. /** The fragment of the URL */
  4272. fragment?: string | null);
  4273. get queryParamMap(): ParamMap;
  4274. /** @docsNotRequired */
  4275. toString(): string;
  4276. }
  4277. /**
  4278. * @publicApi
  4279. */
  4280. export declare const VERSION: Version;
  4281. /**
  4282. * Enables binding information from the `Router` state directly to the inputs of the component in
  4283. * `Route` configurations.
  4284. *
  4285. * @usageNotes
  4286. *
  4287. * Basic example of how you can enable the feature:
  4288. * ```
  4289. * const appRoutes: Routes = [];
  4290. * bootstrapApplication(AppComponent,
  4291. * {
  4292. * providers: [
  4293. * provideRouter(appRoutes, withComponentInputBinding())
  4294. * ]
  4295. * }
  4296. * );
  4297. * ```
  4298. *
  4299. * @returns A set of providers for use with `provideRouter`.
  4300. */
  4301. export declare function withComponentInputBinding(): ComponentInputBindingFeature;
  4302. /**
  4303. * Enables logging of all internal navigation events to the console.
  4304. * Extra logging might be useful for debugging purposes to inspect Router event sequence.
  4305. *
  4306. * @usageNotes
  4307. *
  4308. * Basic example of how you can enable debug tracing:
  4309. * ```
  4310. * const appRoutes: Routes = [];
  4311. * bootstrapApplication(AppComponent,
  4312. * {
  4313. * providers: [
  4314. * provideRouter(appRoutes, withDebugTracing())
  4315. * ]
  4316. * }
  4317. * );
  4318. * ```
  4319. *
  4320. * @see `provideRouter`
  4321. *
  4322. * @returns A set of providers for use with `provideRouter`.
  4323. *
  4324. * @publicApi
  4325. */
  4326. export declare function withDebugTracing(): DebugTracingFeature;
  4327. /**
  4328. * Disables initial navigation.
  4329. *
  4330. * Use if there is a reason to have more control over when the router starts its initial navigation
  4331. * due to some complex initialization logic.
  4332. *
  4333. * @usageNotes
  4334. *
  4335. * Basic example of how you can disable initial navigation:
  4336. * ```
  4337. * const appRoutes: Routes = [];
  4338. * bootstrapApplication(AppComponent,
  4339. * {
  4340. * providers: [
  4341. * provideRouter(appRoutes, withDisabledInitialNavigation())
  4342. * ]
  4343. * }
  4344. * );
  4345. * ```
  4346. *
  4347. * @see `provideRouter`
  4348. *
  4349. * @returns A set of providers for use with `provideRouter`.
  4350. *
  4351. * @publicApi
  4352. */
  4353. export declare function withDisabledInitialNavigation(): DisabledInitialNavigationFeature;
  4354. /**
  4355. * Configures initial navigation to start before the root component is created.
  4356. *
  4357. * The bootstrap is blocked until the initial navigation is complete. This value is required for
  4358. * [server-side rendering](guide/universal) to work.
  4359. *
  4360. * @usageNotes
  4361. *
  4362. * Basic example of how you can enable this navigation behavior:
  4363. * ```
  4364. * const appRoutes: Routes = [];
  4365. * bootstrapApplication(AppComponent,
  4366. * {
  4367. * providers: [
  4368. * provideRouter(appRoutes, withEnabledBlockingInitialNavigation())
  4369. * ]
  4370. * }
  4371. * );
  4372. * ```
  4373. *
  4374. * @see `provideRouter`
  4375. *
  4376. * @publicApi
  4377. * @returns A set of providers for use with `provideRouter`.
  4378. */
  4379. export declare function withEnabledBlockingInitialNavigation(): EnabledBlockingInitialNavigationFeature;
  4380. /**
  4381. * Provides the location strategy that uses the URL fragment instead of the history API.
  4382. *
  4383. * @usageNotes
  4384. *
  4385. * Basic example of how you can use the hash location option:
  4386. * ```
  4387. * const appRoutes: Routes = [];
  4388. * bootstrapApplication(AppComponent,
  4389. * {
  4390. * providers: [
  4391. * provideRouter(appRoutes, withHashLocation())
  4392. * ]
  4393. * }
  4394. * );
  4395. * ```
  4396. *
  4397. * @see `provideRouter`
  4398. * @see `HashLocationStrategy`
  4399. *
  4400. * @returns A set of providers for use with `provideRouter`.
  4401. *
  4402. * @publicApi
  4403. */
  4404. export declare function withHashLocation(): RouterConfigurationFeature;
  4405. /**
  4406. * Enables customizable scrolling behavior for router navigations.
  4407. *
  4408. * @usageNotes
  4409. *
  4410. * Basic example of how you can enable scrolling feature:
  4411. * ```
  4412. * const appRoutes: Routes = [];
  4413. * bootstrapApplication(AppComponent,
  4414. * {
  4415. * providers: [
  4416. * provideRouter(appRoutes, withInMemoryScrolling())
  4417. * ]
  4418. * }
  4419. * );
  4420. * ```
  4421. *
  4422. * @see `provideRouter`
  4423. * @see `ViewportScroller`
  4424. *
  4425. * @publicApi
  4426. * @param options Set of configuration parameters to customize scrolling behavior, see
  4427. * `InMemoryScrollingOptions` for additional information.
  4428. * @returns A set of providers for use with `provideRouter`.
  4429. */
  4430. export declare function withInMemoryScrolling(options?: InMemoryScrollingOptions): InMemoryScrollingFeature;
  4431. /**
  4432. * Subscribes to the Router's navigation events and calls the given function when a
  4433. * `NavigationError` happens.
  4434. *
  4435. * This function is run inside application's injection context so you can use the `inject` function.
  4436. *
  4437. * @usageNotes
  4438. *
  4439. * Basic example of how you can use the error handler option:
  4440. * ```
  4441. * const appRoutes: Routes = [];
  4442. * bootstrapApplication(AppComponent,
  4443. * {
  4444. * providers: [
  4445. * provideRouter(appRoutes, withNavigationErrorHandler((e: NavigationError) =>
  4446. * inject(MyErrorTracker).trackError(e)))
  4447. * ]
  4448. * }
  4449. * );
  4450. * ```
  4451. *
  4452. * @see `NavigationError`
  4453. * @see `inject`
  4454. * @see `EnvironmentInjector#runInContext`
  4455. *
  4456. * @returns A set of providers for use with `provideRouter`.
  4457. *
  4458. * @publicApi
  4459. */
  4460. export declare function withNavigationErrorHandler(fn: (error: NavigationError) => void): NavigationErrorHandlerFeature;
  4461. /**
  4462. * Allows to configure a preloading strategy to use. The strategy is configured by providing a
  4463. * reference to a class that implements a `PreloadingStrategy`.
  4464. *
  4465. * @usageNotes
  4466. *
  4467. * Basic example of how you can configure preloading:
  4468. * ```
  4469. * const appRoutes: Routes = [];
  4470. * bootstrapApplication(AppComponent,
  4471. * {
  4472. * providers: [
  4473. * provideRouter(appRoutes, withPreloading(PreloadAllModules))
  4474. * ]
  4475. * }
  4476. * );
  4477. * ```
  4478. *
  4479. * @see `provideRouter`
  4480. *
  4481. * @param preloadingStrategy A reference to a class that implements a `PreloadingStrategy` that
  4482. * should be used.
  4483. * @returns A set of providers for use with `provideRouter`.
  4484. *
  4485. * @publicApi
  4486. */
  4487. export declare function withPreloading(preloadingStrategy: Type<PreloadingStrategy>): PreloadingFeature;
  4488. /**
  4489. * Allows to provide extra parameters to configure Router.
  4490. *
  4491. * @usageNotes
  4492. *
  4493. * Basic example of how you can provide extra configuration options:
  4494. * ```
  4495. * const appRoutes: Routes = [];
  4496. * bootstrapApplication(AppComponent,
  4497. * {
  4498. * providers: [
  4499. * provideRouter(appRoutes, withRouterConfig({
  4500. * onSameUrlNavigation: 'reload'
  4501. * }))
  4502. * ]
  4503. * }
  4504. * );
  4505. * ```
  4506. *
  4507. * @see `provideRouter`
  4508. *
  4509. * @param options A set of parameters to configure Router, see `RouterConfigOptions` for
  4510. * additional information.
  4511. * @returns A set of providers for use with `provideRouter`.
  4512. *
  4513. * @publicApi
  4514. */
  4515. export declare function withRouterConfig(options: RouterConfigOptions): RouterConfigurationFeature;
  4516. /**
  4517. * Performs the given action once the router finishes its next/current navigation.
  4518. *
  4519. * The navigation is considered complete under the following conditions:
  4520. * - `NavigationCancel` event emits and the code is not `NavigationCancellationCode.Redirect` or
  4521. * `NavigationCancellationCode.SupersededByNewNavigation`. In these cases, the
  4522. * redirecting/superseding navigation must finish.
  4523. * - `NavigationError`, `NavigationEnd`, or `NavigationSkipped` event emits
  4524. */
  4525. export declare function ɵafterNextNavigation(router: {
  4526. events: Observable<Event_2>;
  4527. }, action: () => void): void;
  4528. /**
  4529. * This component is used internally within the router to be a placeholder when an empty
  4530. * router-outlet is needed. For example, with a config such as:
  4531. *
  4532. * `{path: 'parent', outlet: 'nav', children: [...]}`
  4533. *
  4534. * In order to render, there needs to be a component on this config, which will default
  4535. * to this `EmptyOutletComponent`.
  4536. */
  4537. export declare class ɵEmptyOutletComponent {
  4538. static ɵfac: i0.ɵɵFactoryDeclaration<ɵEmptyOutletComponent, never>;
  4539. static ɵcmp: i0.ɵɵComponentDeclaration<ɵEmptyOutletComponent, "ng-component", never, {}, {}, never, never, true, never>;
  4540. }
  4541. export declare type ɵRestoredState = {
  4542. [k: string]: any;
  4543. navigationId: number;
  4544. ɵrouterPageId?: number;
  4545. };
  4546. export declare const ɵROUTER_PROVIDERS: Provider[];
  4547. export { }