<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Pramod Patil on Medium]]></title>
        <description><![CDATA[Stories by Pramod Patil on Medium]]></description>
        <link>https://medium.com/@itsyou?source=rss-919fc4aeecef------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*roXhLzx6sfNNQsNsaxvzOg.jpeg</url>
            <title>Stories by Pramod Patil on Medium</title>
            <link>https://medium.com/@itsyou?source=rss-919fc4aeecef------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 07:33:33 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@itsyou/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Angular Dynamic Routes with Easy Example]]></title>
            <link>https://medium.com/@itsyou/angular-dynamic-routes-with-easy-example-c3fa64fbc768?source=rss-919fc4aeecef------2</link>
            <guid isPermaLink="false">https://medium.com/p/c3fa64fbc768</guid>
            <category><![CDATA[angular-router]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[angular-dynamic-routing]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[angular-routing]]></category>
            <dc:creator><![CDATA[Pramod Patil]]></dc:creator>
            <pubDate>Thu, 28 Nov 2019 09:31:32 GMT</pubDate>
            <atom:updated>2019-11-28T09:31:32.164Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k-U0cz6c1IlPmT-lx_WkSA.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/photos/br9D5K3UTRQ">Edouard Ki</a> on <a href="https://unsplash.com/photos/br9D5K3UTRQ">Unplash</a></figcaption></figure><p>In this article, I am going to show you an easy way to set up Angular Dynamic Routing using Angular Router feature.</p><h4><strong>Step 1: Setup Project</strong></h4><p>Create Project using following Angular CLI command.</p><pre><em>ng new article-routing</em></pre><h4><strong>Step 2: Create Component</strong></h4><p>Open that project and create component using follwing command. ( if your using VS code use ctrl+` to open and close command prompt ).</p><pre>ng g c article</pre><h4><strong>Step 3: Setup Dyanamic Route</strong></h4><p>Open app-routing.module.ts file and add path name and component in “Routes” Array (app-routing.module.ts file created automatically in project when create project).</p><pre>const routes: Routes = [<br>{  <br>  path:&#39;&#39;,<br>  component: ArticleComponent<br>},<br>{<br>  path: &#39;article&#39;,<br>  component: ArticleComponent,<br>  children:[<br>             {<br>               path:&#39;article/:type&#39;, //:type is dynamic here<br>               component:ArticleComponent<br>             }<br>           ]</pre><pre>}<br>];</pre><h4>Step 4: Import Router and create instance of Router in article Component</h4><p>Open <strong><em>article.component.ts</em></strong> file and import Router and create instance of that.</p><pre>import { Component, OnInit } from &#39;@angular/core&#39;;<br>import { Router } from &#39;@angular/router&#39;; //<strong>import router</strong></pre><pre>@Component({<br>selector: &#39;app-article&#39;,<br>templateUrl: &#39;./article.component.html&#39;,<br>styleUrls: [&#39;./article.component.css&#39;]<br>})</pre><pre>export class ArticleComponent implements OnInit {<br>constructor(public router:Router) { }  //<strong>create instance</strong><br>ngOnInit() {}<br>}</pre><h4>Step 5: Pass dynamically route type</h4><p>open <strong><em>article.component.html</em></strong> file and write following logic. On every button click dynamic type parameter is passed using routerLink. And added condition on every paragrap ( &lt;p&gt; tag).</p><pre>&lt;h2&gt;Article&lt;/h2&gt;</pre><pre>&lt;button type=&quot;button&quot; routerLink=&#39;/article/trending&#39;&gt; Trending&lt;/button&gt;&amp;nbsp;<br>&lt;button type=&quot;button&quot; routerLink=&#39;/article/politics&#39;&gt; Politics&lt;/button&gt;&amp;nbsp;<br>&lt;button type=&quot;button&quot; routerLink=&#39;/article/business&#39;&gt; Business&lt;/button&gt;&amp;nbsp;<br>&lt;button type=&quot;button&quot; routerLink=&#39;/article/social&#39;&gt; Social&lt;/button&gt;&amp;nbsp;<br>&lt;button type=&quot;button&quot; routerLink=&#39;/article/bollywoodHollywood&#39;&gt; Bollywood/Hollywood&lt;/button&gt;</pre><pre>&lt;p *ngIf=&#39;router.url.includes(&quot;trending&quot;)&#39;&gt;Your are in Trending Section&lt;/p&gt;<br>&lt;p *ngIf=&#39;router.url.includes(&quot;politics&quot;)&#39;&gt;Your are in Politics Section&lt;/p&gt;<br>&lt;p *ngIf=&#39;router.url.includes(&quot;business&quot;)&#39;&gt;Your are in Business Section&lt;/p&gt;<br>&lt;p *ngIf=&#39;router.url.includes(&quot;social&quot;)&#39;&gt;Your are in Social Section&lt;/p&gt;<br>&lt;p *ngIf=&#39;router.url.includes(&quot;bollywoodHollywood&quot;)&#39;&gt;Your are in Bollywood/Hollywood Section&lt;/p&gt;</pre><p>Now , serve the project using Angular CLI command</p><pre>ng serve</pre><p>Now you can see changes on button click. (if you are a begineer , after ng serve , project will serve on <strong>localhost:4200 </strong>which is default port of angular)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c3fa64fbc768" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>