{"id":54,"date":"2019-10-07T10:25:13","date_gmt":"2019-10-07T10:25:13","guid":{"rendered":"https:\/\/docs.theironnetwork.org\/embryo\/?page_id=54"},"modified":"2019-10-15T09:38:58","modified_gmt":"2019-10-15T09:38:58","slug":"routing-navigation","status":"publish","type":"page","link":"https:\/\/docs.theironnetwork.org\/embryo\/routing-navigation\/","title":{"rendered":"Routing\/Navigation"},"content":{"rendered":"\n<p>Go to src &gt;&gt; app &gt;&gt; and open app.routing.ts file and add routing like this:-<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">{ path: 'about\/:keyword',component: AboutComponent }<br>{ path: 'cart', component: CartComponent }<\/pre>\n\n\n\n<p>For Reference: <a href=\"https:\/\/angular.io\/guide\/router\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/angular.io\/guide\/router<\/a>\u200b\u200c<\/p>\n\n\n\n<h6 id=\"1-router-navigate-with-params\"><strong>1. Router navigate with params<\/strong><\/h6>\n\n\n\n<p>If you want to use this routing in component.  then go to src &gt;&gt; app &gt;&gt; and open component.ts file then do the followings:-\u200c<\/p>\n\n\n\n<p>a) Add the the routing at top of the file like this:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">import { Router} from '@angular\/router';constructor(private router: Router){}<\/pre>\n\n\n\n<p>b) Add in your desire component and add these line of code in your function:- For Example:-<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">gotoAbout(){ <br>    this.router.navigate(['\/about'], { queryParams: { keyword: 'Test' } });<br>}<\/pre>\n\n\n\n<p>For Reference :- <a href=\"https:\/\/alligator.io\/angular\/query-parameters\/\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/alligator.io\/angular\/query-parameters\/<\/a>\u200b\u200c<\/p>\n\n\n\n<h6 id=\"2-routerlink-and-routerlinkactive\"><strong>2. RouterLink and RouterLinkActive<\/strong><\/h6>\n\n\n\n<p>When the HTML element with RouterLink binding is clicked then the CSS classes bound with RouterLinkActive will be active. These directives are used are follows.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;a routerLink=\"\/cart\" routerLinkActive=\"active-link\"&gt;Cart&lt;\/a&gt;&lt;a [routerLink]=\"['\/cart']\"&gt;Cart&lt;\/a&gt; <\/pre>\n\n\n\n<p>For Reference :- <a href=\"https:\/\/angular.io\/guide\/router#router-links\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/angular.io\/guide\/router#router-links<\/a>\u200b\u200c<\/p>\n\n\n\n<h6 id=\"3-lazy-loading\"><strong>3. Lazy Loading<\/strong><\/h6>\n\n\n\n<p>Lazy Loading in Embryo we need to create a routing module and a module for that component. \u200c<\/p>\n\n\n\n<p>1.Go to src &gt;&gt; app &gt;&gt; and open app.routing.ts file and add routing like this:-<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">{   <br>     path: 'products',   <br>     loadChildren: '.\/Products\/Products.module#ProductsModule'<br>}<\/pre>\n\n\n\n<p>2. Inside the products module routing, Go to src &gt;&gt; app &gt;&gt; Products and open Products.routing.ts file and add routing like this:- <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">{ path: '', component: ProductsListComponent }<\/pre>\n\n\n\n<p>For Reference :- <a href=\"https:\/\/angular.io\/guide\/lazy-loading-ngmodules\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/angular.io\/guide\/lazy-loading-ngmodules<\/a>\u200b<\/p>\n<div class=\"pld-like-dislike-wrap pld-template-1\">\n    <div class=\"pld-like-wrap  pld-common-wrap\">\n    <a href=\"javascript:void(0);\" class=\"pld-like-trigger pld-like-dislike-trigger \" title=\"\" data-post-id=\"54\" data-trigger-type=\"like\" data-restriction=\"cookie\" data-ip-check=\"0\" data-user-check=\"1\">\n                        <i class=\"fas fa-thumbs-up\"><\/i>\n                    <\/a>\n    <span class=\"pld-like-count-wrap pld-count-wrap\">    <\/span>\n<\/div><div class=\"pld-dislike-wrap  pld-common-wrap\">\n    <a href=\"javascript:void(0);\" class=\"pld-dislike-trigger pld-like-dislike-trigger \" title=\"\" data-post-id=\"54\" data-trigger-type=\"dislike\" data-ip-check=\"0\" data-restriction=\"cookie\" data-user-check=\"1\">\n                        <i class=\"fas fa-thumbs-down\"><\/i>\n                    <\/a>\n    <span class=\"pld-dislike-count-wrap pld-count-wrap\"><\/span>\n<\/div><\/div>\n\n","protected":false},"excerpt":{"rendered":"<p>Go to src &gt;&gt; app &gt;&gt; and open app.routing.ts file and add routing like this:- { path: &#8216;about\/:keyword&#8217;,component: AboutComponent }{ path: &#8216;cart&#8217;, component: CartComponent } For Reference: https:\/\/angular.io\/guide\/router\u200b\u200c 1. Router navigate with params If you want to use this routing in component. then go to src &gt;&gt; app &gt;&gt; and open component.ts file then do [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":9,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"_links":{"self":[{"href":"https:\/\/docs.theironnetwork.org\/embryo\/wp-json\/wp\/v2\/pages\/54"}],"collection":[{"href":"https:\/\/docs.theironnetwork.org\/embryo\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/docs.theironnetwork.org\/embryo\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/docs.theironnetwork.org\/embryo\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.theironnetwork.org\/embryo\/wp-json\/wp\/v2\/comments?post=54"}],"version-history":[{"count":9,"href":"https:\/\/docs.theironnetwork.org\/embryo\/wp-json\/wp\/v2\/pages\/54\/revisions"}],"predecessor-version":[{"id":288,"href":"https:\/\/docs.theironnetwork.org\/embryo\/wp-json\/wp\/v2\/pages\/54\/revisions\/288"}],"wp:attachment":[{"href":"https:\/\/docs.theironnetwork.org\/embryo\/wp-json\/wp\/v2\/media?parent=54"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}