{"id":59890,"date":"2018-05-03T15:58:02","date_gmt":"2018-05-03T10:28:02","guid":{"rendered":"https:\/\/www.vskills.in\/certification\/tutorial\/?p=59890"},"modified":"2024-04-12T14:20:49","modified_gmt":"2024-04-12T08:50:49","slug":"angular-router-links","status":"publish","type":"page","link":"https:\/\/www.vskills.in\/certification\/tutorial\/angular-router-links\/","title":{"rendered":"Angular Router Links"},"content":{"rendered":"<h1>Angular Router Links<\/h1>\n<p>Angular Router has Angular routes, which is an array of route configurations. Each Angular router has the Angular routes, which have the following properties:<\/p>\n<p>path is a string that uses the route matcher DSL.<br \/>\npathMatch is a string that specifies the matching strategy.<br \/>\nmatcher defines a custom strategy for path matching and supersedes path and pathMatch.<br \/>\ncomponent is a component type.<br \/>\nredirectTo is the url fragment which will replace the current matched segment.<br \/>\noutlet is the name of the outlet the component should be placed into.<br \/>\ncanActivate is an array of DI tokens used to look up CanActivate handlers.<br \/>\ncanActivateChild is an array of DI tokens used to look up CanActivateChild handlers.<br \/>\ncanDeactivate is an array of DI tokens used to look up CanDeactivate handlers.<br \/>\ncanLoad is an array of DI tokens used to look up CanLoad handlers.<br \/>\ndata is additional data provided to the component via ActivatedRoute.<br \/>\nresolve is a map of DI tokens used to look up data resolvers.<br \/>\nrunGuardsAndResolvers defines when guards and resolvers will be run. By default they run only when the matrix parameters of the route change. When set to paramsOrQueryParamsChange they will also run when query params change. And when set to always, they will run every time.<br \/>\nchildren is an array of child route definitions.<br \/>\nloadChildren is a reference to lazy loaded child routes.<\/p>\n<p><strong>RouterLink<\/strong><\/p>\n<p>Overview<br \/>\n@Directive({ selector: &#8216;:not(a)[routerLink]&#8217; })<br \/>\nclass RouterLink {<br \/>\nqueryParams: {&#8230;}<br \/>\nfragment: string<br \/>\nqueryParamsHandling: QueryParamsHandling<br \/>\npreserveFragment: boolean<br \/>\nskipLocationChange: boolean<br \/>\nreplaceUrl: boolean<br \/>\nset routerLink: any[] | string<br \/>\nset preserveQueryParams: boolean<br \/>\nonClick(): boolean<br \/>\nget urlTree: UrlTree<br \/>\n}<\/p>\n<p>How To Use<br \/>\nConsider the following route configuration: [{ path: &#8216;user\/:name&#8217;, component: UserCmp }]\n<p>When linking to this user\/:name route, you can write: &lt;a routerLink=&#8217;\/user\/bob&#8217;&gt;link to user component&lt;\/a&gt;<\/p>\n<p>Selectors<br \/>\n:not(a)[routerLink]\n<p>Inputs<br \/>\nqueryParams bound to RouterLink.queryParams<br \/>\nfragment bound to RouterLink.fragment<br \/>\nqueryParamsHandling bound to RouterLink.queryParamsHandling<br \/>\npreserveFragment bound to RouterLink.preserveFragment<br \/>\nskipLocationChange bound to RouterLink.skipLocationChange<br \/>\nreplaceUrl bound to RouterLink.replaceUrl<br \/>\nrouterLink bound to RouterLink.routerLink<br \/>\npreserveQueryParams bound to RouterLink.preserveQueryParams<\/p>\n<p>Description<br \/>\nThe RouterLink directives let you link to specific parts of your app.<\/p>\n<p>When the link is static, you can use the directive as follows: &lt;a routerLink=&#8221;\/user\/bob&#8221;&gt;link to user component&lt;\/a&gt;<\/p>\n<p>If you use dynamic values to generate the link, you can pass an array of path segments, followed by the params for each segment.<\/p>\n<p>For instance [&#8216;\/team&#8217;, teamId, &#8216;user&#8217;, userName, {details: true}] means that we want to generate a link to \/team\/11\/user\/bob;details=true.<\/p>\n<p>Multiple static segments can be merged into one (e.g., [&#8216;\/team\/11\/user&#8217;, userName, {details: true}]).<\/p>\n<p>The first segment name can be prepended with \/, .\/, or ..\/:<\/p>\n<p>If the first segment begins with \/, the router will look up the route from the root of the app.<br \/>\nIf the first segment begins with .\/, or doesn&#8217;t begin with a slash, the router will instead look in the children of the current activated route.<br \/>\nAnd if the first segment begins with ..\/, the router will go up one level.<\/p>\n<p>You can set query params and fragment as follows:<\/p>\n<p>&lt;a [routerLink]=&#8221;[&#8216;\/user\/bob&#8217;]&#8221; [queryParams]=&#8221;{debug: true}&#8221; fragment=&#8221;education&#8221;&gt;<br \/>\nlink to user component<br \/>\n&lt;\/a&gt;<\/p>\n<p>RouterLink will use these to generate this link: \/user\/bob#education?debug=true.<\/p>\n<p>(Deprecated in v4.0.0 use queryParamsHandling instead) You can also tell the directive to preserve the current query params and fragment:<\/p>\n<p>&lt;a [routerLink]=&#8221;[&#8216;\/user\/bob&#8217;]&#8221; preserveQueryParams preserveFragment&gt;<br \/>\nlink to user component<br \/>\n&lt;\/a&gt;<\/p>\n<p>You can tell the directive to how to handle queryParams, available options are:<\/p>\n<p>&#8216;merge&#8217;: merge the queryParams into the current queryParams<br \/>\n&#8216;preserve&#8217;: preserve the current queryParams<br \/>\ndefault\/&#8221;: use the queryParams only<\/p>\n<p>Same options for NavigationExtras#queryParamsHandling.<\/p>\n<p>&lt;a [routerLink]=&#8221;[&#8216;\/user\/bob&#8217;]&#8221; [queryParams]=&#8221;{debug: true}&#8221; queryParamsHandling=&#8221;merge&#8221;&gt;<br \/>\nlink to user component<br \/>\n&lt;\/a&gt;<\/p>\n<p>The router link directive always treats the provided input as a delta to the current url.<\/p>\n<p>For instance, if the current url is \/user\/(box\/\/aux:team).<\/p>\n<p>Then the following link &lt;a [routerLink]=&#8221;[&#8216;\/user\/jim&#8217;]&#8221;&gt;Jim&lt;\/a&gt; will generate the link \/user\/(jim\/\/aux:team).<\/p>\n<p>Constructor<br \/>\nconstructor(router: Router, route: ActivatedRoute, tabIndex: string, renderer: Renderer2, el: ElementRef)<\/p>\n<p>Members<br \/>\nqueryParams: {<br \/>\n[k: string]: any;<br \/>\n}<\/p>\n<p>fragment: string<br \/>\nqueryParamsHandling: QueryParamsHandling<br \/>\npreserveFragment: boolean<br \/>\nskipLocationChange: boolean<br \/>\nreplaceUrl: boolean<br \/>\nset routerLink: any[] | string<br \/>\nset preserveQueryParams: boolean<br \/>\nonClick(): boolean<br \/>\nget urlTree: UrlTree<\/p>\n<p>&nbsp;<\/p>\n<p class=\"VSKILLbodytext\"><strong>IT Professionals, Web Developers, web programmers, IT students can Apply for the certification course and get ahead.<\/strong><\/p>\n<p><a href=\"https:\/\/www.vskills.in\/certification\/web-development\/angular-4-certification\" rel=\"attachment wp-att-61497\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-61497\" src=\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2018\/04\/Angular-4.png\" sizes=\"auto, (max-width: 1050px) 100vw, 1050px\" srcset=\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2018\/04\/Angular-4.png 1050w, https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2018\/04\/Angular-4-300x48.png 300w, https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2018\/04\/Angular-4-768x124.png 768w, https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2018\/04\/Angular-4-1024x165.png 1024w, https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2018\/04\/Angular-4-712x115.png 712w\" alt=\"\" width=\"1050\" height=\"169\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<ul>\n<li class=\"VSKILLbodytext\"><a href=\"https:\/\/www.vskills.in\/practice\/skills\/Web-Development\/Angular-4\" target=\"_blank\" rel=\"noopener\">Practice Test for Angular4 <\/a><\/li>\n<li class=\"VSKILLbodytext\"><a href=\"https:\/\/www.vskills.in\/certification\/web-development\/angular-4-certification\" target=\"_blank\" rel=\"noopener\">Govt Certification in Angular 4<\/a><\/li>\n<li><a href=\"https:\/\/www.vskills.in\/certification\/blog\/\">Blog posts on Angular 4 and Web Development<\/a><\/li>\n<\/ul>\n<p><a href=\"https:\/\/www.vskills.in\/certification\/tutorial\/web-development\/angular-4\/\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-55483 size-full\" src=\"http:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/05\/Back-Arrow.jpg\" alt=\"Angular 4 Tutorial Index\" width=\"47\" height=\"52\" \/>Back to Angular 4 Tutorial Main Page <\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Angular Router Links Angular Router has Angular routes, which is an array of route configurations. Each Angular router has the Angular routes, which have the following properties: path is a string that uses the route matcher DSL. pathMatch is a string that specifies the matching strategy. matcher defines a custom strategy for path matching and&#8230;<\/p>\n","protected":false},"author":10,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"categories":[7230,5743],"tags":[7221,7227,7235,7236,7226,7234,7405,7404,7403,7232,7223,7233],"class_list":["post-59890","page","type-page","status-publish","hentry","category-angular-2","category-web-development","tag-angular","tag-angular-4","tag-angular-4-tutorial","tag-angular-cli","tag-angular-js","tag-angular-js-tutorial","tag-angular-router","tag-angular-router-link","tag-angular-router-links","tag-angular-tutorial","tag-angularjs","tag-angularjs-tutorial"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Angular Router Links - Tutorial<\/title>\n<meta name=\"description\" content=\"Angular Router Links: has Angular routes, which is an array of route configurations. Each Angular router has the Angular routes. Click here.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.vskills.in\/certification\/tutorial\/angular-router-links\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Angular Router Links - Tutorial\" \/>\n<meta property=\"og:description\" content=\"Angular Router Links: has Angular routes, which is an array of route configurations. Each Angular router has the Angular routes. Click here.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.vskills.in\/certification\/tutorial\/angular-router-links\/\" \/>\n<meta property=\"og:site_name\" content=\"Tutorial\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/vskills.in\/\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-12T08:50:49+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2018\/04\/Angular-4.png\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/angular-router-links\/\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/angular-router-links\/\",\"name\":\"Angular Router Links - Tutorial\",\"isPartOf\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/angular-router-links\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/angular-router-links\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2018\/04\/Angular-4.png\",\"datePublished\":\"2018-05-03T10:28:02+00:00\",\"dateModified\":\"2024-04-12T08:50:49+00:00\",\"description\":\"Angular Router Links: has Angular routes, which is an array of route configurations. Each Angular router has the Angular routes. Click here.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/angular-router-links\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.vskills.in\/certification\/tutorial\/angular-router-links\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/angular-router-links\/#primaryimage\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2018\/04\/Angular-4.png\",\"contentUrl\":\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2018\/04\/Angular-4.png\",\"width\":1050,\"height\":169},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/angular-router-links\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Angular Router Links\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#website\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\",\"name\":\"Tutorial\",\"description\":\"Vskills - A initiative in elearning and certification\",\"publisher\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.vskills.in\/certification\/tutorial\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#organization\",\"name\":\"Vskills\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg\",\"contentUrl\":\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg\",\"width\":73,\"height\":55,\"caption\":\"Vskills\"},\"image\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/vskills.in\/\",\"https:\/\/x.com\/vskills_in\",\"https:\/\/www.linkedin.com\/company-beta\/1371554\/\",\"https:\/\/www.youtube.com\/channel\/UCMWnscxPwRF_PqXo9B7q_Tw\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Angular Router Links - Tutorial","description":"Angular Router Links: has Angular routes, which is an array of route configurations. Each Angular router has the Angular routes. Click here.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.vskills.in\/certification\/tutorial\/angular-router-links\/","og_locale":"en_US","og_type":"article","og_title":"Angular Router Links - Tutorial","og_description":"Angular Router Links: has Angular routes, which is an array of route configurations. Each Angular router has the Angular routes. Click here.","og_url":"https:\/\/www.vskills.in\/certification\/tutorial\/angular-router-links\/","og_site_name":"Tutorial","article_publisher":"https:\/\/www.facebook.com\/vskills.in\/","article_modified_time":"2024-04-12T08:50:49+00:00","og_image":[{"url":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2018\/04\/Angular-4.png","type":"","width":"","height":""}],"twitter_misc":{"Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/angular-router-links\/","url":"https:\/\/www.vskills.in\/certification\/tutorial\/angular-router-links\/","name":"Angular Router Links - Tutorial","isPartOf":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/angular-router-links\/#primaryimage"},"image":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/angular-router-links\/#primaryimage"},"thumbnailUrl":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2018\/04\/Angular-4.png","datePublished":"2018-05-03T10:28:02+00:00","dateModified":"2024-04-12T08:50:49+00:00","description":"Angular Router Links: has Angular routes, which is an array of route configurations. Each Angular router has the Angular routes. Click here.","breadcrumb":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/angular-router-links\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.vskills.in\/certification\/tutorial\/angular-router-links\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/angular-router-links\/#primaryimage","url":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2018\/04\/Angular-4.png","contentUrl":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2018\/04\/Angular-4.png","width":1050,"height":169},{"@type":"BreadcrumbList","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/angular-router-links\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.vskills.in\/certification\/tutorial\/"},{"@type":"ListItem","position":2,"name":"Angular Router Links"}]},{"@type":"WebSite","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#website","url":"https:\/\/www.vskills.in\/certification\/tutorial\/","name":"Tutorial","description":"Vskills - A initiative in elearning and certification","publisher":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.vskills.in\/certification\/tutorial\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#organization","name":"Vskills","url":"https:\/\/www.vskills.in\/certification\/tutorial\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/","url":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg","contentUrl":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg","width":73,"height":55,"caption":"Vskills"},"image":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/vskills.in\/","https:\/\/x.com\/vskills_in","https:\/\/www.linkedin.com\/company-beta\/1371554\/","https:\/\/www.youtube.com\/channel\/UCMWnscxPwRF_PqXo9B7q_Tw"]}]}},"_links":{"self":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/59890","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/comments?post=59890"}],"version-history":[{"count":6,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/59890\/revisions"}],"predecessor-version":[{"id":64253,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/59890\/revisions\/64253"}],"wp:attachment":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/media?parent=59890"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/categories?post=59890"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/tags?post=59890"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}