<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	
xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
>

<channel>
	<title>router - Bipon's Diary</title>
	<atom:link href="https://biponnotes.iglyphic.com/tag/router/feed/" rel="self" type="application/rss+xml" />
	<link>https://biponnotes.iglyphic.com</link>
	<description>Do good for others. It will come back in unexpected ways.</description>
	<lastBuildDate>Thu, 02 Jan 2020 10:36:19 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.9.10</generator>
<site xmlns="com-wordpress:feed-additions:1">168324471</site>	<item>
		<title>Lazy loading modules</title>
		<link>https://biponnotes.iglyphic.com/lazy-loading-modules/</link>
					<comments>https://biponnotes.iglyphic.com/lazy-loading-modules/#respond</comments>
		
		<dc:creator><![CDATA[bipon68]]></dc:creator>
		<pubDate>Thu, 02 Jan 2020 10:36:13 +0000</pubDate>
				<category><![CDATA[Angular Router]]></category>
		<category><![CDATA[lazy]]></category>
		<category><![CDATA[module]]></category>
		<category><![CDATA[route]]></category>
		<category><![CDATA[router]]></category>
		<category><![CDATA[routes]]></category>
		<guid isPermaLink="false">https://bipon.me/?p=301</guid>

					<description><![CDATA[<p>Step 1: Create a user folder then create a component user.profile.component.ts user.module.ts user.routes.ts routes.ts nav-bar.component.html</p>
<p>The post <a href="https://biponnotes.iglyphic.com/lazy-loading-modules/">Lazy loading modules</a> first appeared on <a href="https://biponnotes.iglyphic.com">Bipon's Diary</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Step 1: Create a user folder then create a component</p>



<p>user.profile.component.ts </p>



<pre class="wp-block-code"><code>import { Component } from '@angular/core'

@Component({
  template: `
    &lt;h1>Edit Your Profile&lt;/h1>
    &lt;hr>
    &lt;div class="col-md-6">
      &lt;h3>[Edit profile form will go here]&lt;/h3>
      &lt;br />
      &lt;br />
      &lt;button type="submit" class="btn btn-primary">Save&lt;/button>
      &lt;button type="button" class="btn btn-default">Cancel&lt;/button>
    &lt;/div>
  `,
})
export class ProfileComponent {
       
}</code></pre>



<p>user.module.ts</p>



<pre class="wp-block-code"><code>import { ProfileComponent } from './profile.component';
import { NgModule } from '@angular/core'
import { CommonModule } from '@angular/common'
import { RouterModule } from '@angular/router'
import { userRoutes } from './user.routes'

@NgModule({
    imports: [
        CommonModule,
        RouterModule.forChild(userRoutes)
    ],
    declarations: [
        ProfileComponent
    ],
    providers: [

    ]

})
export class UserModule{

}</code></pre>



<p>user.routes.ts</p>



<pre class="wp-block-code"><code>import { ProfileComponent } from './profile.component';


export const userRoutes = [
    { path: 'profile', component: ProfileComponent}
]</code></pre>



<p>routes.ts</p>



<pre class="wp-block-code"><code>import { Routes } from '@angular/router'
import { CreateEventComponent } from './app/events/event-details/create-event.component';
import { EventDetailsComponent } from './app/events/event-details/event-details.component';
import { EventListComponent } from './app/events/event-list.component';
import { EventRouteActivator } from './app/events/event-details/event-route.activator.service';
import { EventListResolver } from './app/events/shared/events-list-resolver.service';
import { Error404Component } from './app/errors/404.component';

export const appRoutes:Routes = [
    { path: 'events/new', component: CreateEventComponent, canDeactivate: ['canDeactivateCreateEvent']},
    { path: 'events', component: EventListComponent },
    { path: 'events/:id', component: EventDetailsComponent, canActivate: [EventRouteActivator] },   
    { path: '404', component: Error404Component }, 
    { path: '', redirectTo: '/events', pathMatch: 'full' },
    { path: 'user', loadChildren: './app/user/user.module#UserModule' }
]</code></pre>



<figure class="wp-block-image"><img width="953" height="84" src="https://i2.wp.com/bipon.me/wp-content/uploads/2020/01/5.png?resize=953%2C84&#038;ssl=1" alt="" class="wp-image-302" srcset="https://i0.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/5.png?w=953&amp;ssl=1 953w, https://i0.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/5.png?resize=300%2C26&amp;ssl=1 300w, https://i0.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/5.png?resize=768%2C68&amp;ssl=1 768w, https://i0.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/5.png?resize=750%2C66&amp;ssl=1 750w" sizes="(max-width: 953px) 100vw, 953px" data-recalc-dims="1" /></figure>



<p>nav-bar.component.html</p>



<pre class="wp-block-code"><code>&lt;div class="navbar navbar-default">
    &lt;div class="container-fluid">
      &lt;div class="navbar-header">
        &lt;a class="navbar-brand" >ngEvents&lt;/a>
      &lt;/div>
  
      &lt;div class="collapse navbar-collapse">
        &lt;ul class="nav navbar-nav">
          &lt;li>
            &lt;a [routerLink]="['/events']" routerLinkActive="active"
            [routerLinkActiveOptions]="{exact:true}">All Events&lt;/a>
          &lt;/li>
          &lt;li>&lt;a [routerLink]="['/events/new']" routerLinkActive="active">Create Event&lt;/a>&lt;/li>
          &lt;li class="dropdown">
            &lt;a href="#" class="dropdown-toggle" data-toggle="dropdown" >
              Events
              &lt;span class="caret">&lt;/span>
            &lt;/a>
            &lt;ul class="dropdown-menu">
              &lt;li >
                &lt;a href="">Angular Connect&lt;/a>
              &lt;/li>
            &lt;/ul>
          &lt;/li>
        &lt;/ul>
        &lt;div class="navbar-header navbar-right">
          &lt;ul class="nav navbar-nav">
            &lt;li>
              &lt;a [routerLink]="['user/profile']">Welcome John&lt;/a>
            &lt;/li>
          &lt;/ul>
        &lt;/div>
        &lt;form id="searchForm"  class="navbar-form navbar-right"  >
          &lt;div class="form-group">
            &lt;input type="text" class="form-control" placeholder="Search Sessions" >
          &lt;/div>
          &lt;button class="btn btn-default" >
            Search
          &lt;/button>
        &lt;/form>
      &lt;/div>
    &lt;/div>
  &lt;/div></code></pre>



<figure class="wp-block-image"><img loading="lazy" width="809" height="139" src="https://i0.wp.com/bipon.me/wp-content/uploads/2020/01/6.png?resize=809%2C139&#038;ssl=1" alt="" class="wp-image-303" srcset="https://i0.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/6.png?w=809&amp;ssl=1 809w, https://i0.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/6.png?resize=300%2C52&amp;ssl=1 300w, https://i0.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/6.png?resize=768%2C132&amp;ssl=1 768w, https://i0.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/6.png?resize=750%2C129&amp;ssl=1 750w" sizes="(max-width: 809px) 100vw, 809px" data-recalc-dims="1" /><figcaption>added router link</figcaption></figure><p>The post <a href="https://biponnotes.iglyphic.com/lazy-loading-modules/">Lazy loading modules</a> first appeared on <a href="https://biponnotes.iglyphic.com">Bipon's Diary</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://biponnotes.iglyphic.com/lazy-loading-modules/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">301</post-id>	</item>
		<item>
		<title>Guarding Route De-activation</title>
		<link>https://biponnotes.iglyphic.com/guarding-route-de-activation/</link>
					<comments>https://biponnotes.iglyphic.com/guarding-route-de-activation/#respond</comments>
		
		<dc:creator><![CDATA[bipon68]]></dc:creator>
		<pubDate>Wed, 01 Jan 2020 20:04:58 +0000</pubDate>
				<category><![CDATA[Angular Router]]></category>
		<category><![CDATA[route]]></category>
		<category><![CDATA[router]]></category>
		<category><![CDATA[routes]]></category>
		<guid isPermaLink="false">https://bipon.me/?p=298</guid>

					<description><![CDATA[<p>event-route.activator.service.ts routes.ts app.module.ts</p>
<p>The post <a href="https://biponnotes.iglyphic.com/guarding-route-de-activation/">Guarding Route De-activation</a> first appeared on <a href="https://biponnotes.iglyphic.com">Bipon's Diary</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>event-route.activator.service.ts</p>



<pre class="wp-block-code"><code>import { Injectable } from '@angular/core';
import{ CanActivate, ActivatedRouteSnapshot, Router } from '@angular/router';
import { EventService } from './../shared/event.service';

@Injectable()

export class EventRouteActivator implements CanActivate{

    constructor(private eventService: EventService, private router: Router){}

    canActivate(route: ActivatedRouteSnapshot){
        const eventExists = !!this.eventService.getEvent(+route.params['id']);
        if(!eventExists){
            this.router.navigate(['/404']);
        return eventExists;
        }
    }
}</code></pre>



<p>routes.ts </p>



<pre class="wp-block-code"><code>import { Routes } from '@angular/router'
import { CreateEventComponent } from './app/events/event-details/create-event.component';
import { EventDetailsComponent } from './app/events/event-details/event-details.component';
import { EventListComponent } from './app/events/event-list.component';
import { EventRouteActivator } from './app/events/event-details/event-route.activator.service';
import { Error404Component } from './app/errors/404.component';

export const appRoutes:Routes = [
    { path: 'events/new', component: CreateEventComponent, canDeactivate: ['canDeactivateCreateEvent']},
    { path: 'events', component: EventListComponent },
    { path: 'events/:id', component: EventDetailsComponent, canActivate: [EventRouteActivator] },   
    { path: '404', component: Error404Component }, 
    { path: '', redirectTo: '/events', pathMatch: 'full' }
]</code></pre>



<p>app.module.ts</p>



<pre class="wp-block-code"><code>import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { EventsAppComponent } from './events-app.component';
import { EventListComponent } from './events/event-list.component';
import { EventThumbnailComponent } from './events/event-thumbnail.component';
import { NavBarComponent } from './nav/navbar-component';
import { EventService } from './events/shared/event.service';
import { ToastrService } from './common/toastr.service';
import { EventDetailsComponent } from './events/event-details/event-details.component';
import { RouterModule } from '@angular/router';
import { appRoutes } from 'src/routes';
import { CreateEventComponent } from './events/event-details/create-event.component';
import { Error404Component } from './errors/404.component';
import { EventRouteActivator } from './events/event-details/event-route.activator.service';

@NgModule({
  declarations: [
    EventsAppComponent,
    EventListComponent,
    EventThumbnailComponent,
    NavBarComponent,
    EventDetailsComponent,
    CreateEventComponent,
    Error404Component
  ],
  imports: [
    BrowserModule,
    RouterModule.forRoot(appRoutes)
  ],
  providers: [
    EventService, 
    ToastrService, 
    EventRouteActivator,
      {
        provide:'canDeactivateCreateEvent',
        useValue: checkDirtyState
      }
  ],
  bootstrap: [EventsAppComponent]
})
export class AppModule { }

export function checkDirtyState(component: CreateEventComponent){
  if(component.isDirty)
    return window.confirm('You have not saved this event, do you really want to cancel?')
  return true
}
</code></pre><p>The post <a href="https://biponnotes.iglyphic.com/guarding-route-de-activation/">Guarding Route De-activation</a> first appeared on <a href="https://biponnotes.iglyphic.com">Bipon's Diary</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://biponnotes.iglyphic.com/guarding-route-de-activation/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">298</post-id>	</item>
		<item>
		<title>Guarding Route Activation</title>
		<link>https://biponnotes.iglyphic.com/guarding-route-activation/</link>
					<comments>https://biponnotes.iglyphic.com/guarding-route-activation/#respond</comments>
		
		<dc:creator><![CDATA[bipon68]]></dc:creator>
		<pubDate>Wed, 01 Jan 2020 19:21:22 +0000</pubDate>
				<category><![CDATA[Angular Router]]></category>
		<category><![CDATA[route]]></category>
		<category><![CDATA[router]]></category>
		<category><![CDATA[routes]]></category>
		<guid isPermaLink="false">https://bipon.me/?p=296</guid>

					<description><![CDATA[<p>event-route.activator.service.ts routes.ts app.module.ts</p>
<p>The post <a href="https://biponnotes.iglyphic.com/guarding-route-activation/">Guarding Route Activation</a> first appeared on <a href="https://biponnotes.iglyphic.com">Bipon's Diary</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>event-route.activator.service.ts</p>



<pre class="wp-block-code"><code>import { Injectable } from '@angular/core';
import{ CanActivate, ActivatedRouteSnapshot, Router } from '@angular/router';
import { EventService } from './../shared/event.service';

@Injectable()

export class EventRouteActivator implements CanActivate{

    constructor(private eventService: EventService, private router: Router){}

    canActivate(route: ActivatedRouteSnapshot){
        const eventExists = !!this.eventService.getEvent(+route.params['id']);
        if(!eventExists){
            this.router.navigate(['/404']);
        return eventExists;
        }
    }
}</code></pre>



<p>routes.ts</p>



<pre class="wp-block-code"><code>import { Routes } from '@angular/router'
import { CreateEventComponent } from './app/events/event-details/create-event.component';
import { EventDetailsComponent } from './app/events/event-details/event-details.component';
import { EventListComponent } from './app/events/event-list.component';
import { EventRouteActivator } from './app/events/event-details/event-route.activator.service';
import { Error404Component } from './app/errors/404.component';

export const appRoutes:Routes = [
    { path: 'events/new', component: CreateEventComponent},
    { path: 'events', component: EventListComponent },
    { path: 'events/:id', component: EventDetailsComponent, canActivate: [EventRouteActivator] },   
    { path: '404', component: Error404Component }, 
    { path: '', redirectTo: '/events', pathMatch: 'full' }
]</code></pre>



<p>app.module.ts</p>



<pre class="wp-block-code"><code>import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { EventsAppComponent } from './events-app.component';
import { EventListComponent } from './events/event-list.component';
import { EventThumbnailComponent } from './events/event-thumbnail.component';
import { NavBarComponent } from './nav/navbar-component';
import { EventService } from './events/shared/event.service';
import { ToastrService } from './common/toastr.service';
import { EventDetailsComponent } from './events/event-details/event-details.component';
import { RouterModule } from '@angular/router';
import { appRoutes } from 'src/routes';
import { CreateEventComponent } from './events/event-details/create-event.component';
import { Error404Component } from './errors/404.component';
import { EventRouteActivator } from './events/event-details/event-route.activator.service';

@NgModule({
  declarations: [
    EventsAppComponent,
    EventListComponent,
    EventThumbnailComponent,
    NavBarComponent,
    EventDetailsComponent,
    CreateEventComponent,
    Error404Component
  ],
  imports: [
    BrowserModule,
    RouterModule.forRoot(appRoutes)
  ],
  providers: [EventService, ToastrService, EventRouteActivator],
  bootstrap: [EventsAppComponent]
})
export class AppModule { }
</code></pre><p>The post <a href="https://biponnotes.iglyphic.com/guarding-route-activation/">Guarding Route Activation</a> first appeared on <a href="https://biponnotes.iglyphic.com">Bipon's Diary</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://biponnotes.iglyphic.com/guarding-route-activation/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">296</post-id>	</item>
		<item>
		<title>Navigation from menu</title>
		<link>https://biponnotes.iglyphic.com/navigation-from-menu/</link>
					<comments>https://biponnotes.iglyphic.com/navigation-from-menu/#respond</comments>
		
		<dc:creator><![CDATA[bipon68]]></dc:creator>
		<pubDate>Wed, 01 Jan 2020 18:17:05 +0000</pubDate>
				<category><![CDATA[Angular Router]]></category>
		<category><![CDATA[route]]></category>
		<category><![CDATA[router]]></category>
		<category><![CDATA[routes]]></category>
		<guid isPermaLink="false">https://bipon.me/?p=291</guid>

					<description><![CDATA[<p>Step 1: create a component like create-event.component.ts Step 2: routes.ts file Step 3: createEventComponent component register in app.module.ts file Step 4: add router link in nav html file</p>
<p>The post <a href="https://biponnotes.iglyphic.com/navigation-from-menu/">Navigation from menu</a> first appeared on <a href="https://biponnotes.iglyphic.com">Bipon's Diary</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Step 1: create a component like create-event.component.ts </p>



<pre class="wp-block-code"><code>import { Component } from '@angular/core';
import { Router } from '@angular/router';

@Component({
    template: `
        &lt;h3>New Event&lt;/h3>
        &lt;hr>
        &lt;div class="col-md-6">
        &lt;h3>[Create event from will go here]&lt;/h3>
        &lt;br>
        &lt;br>
            &lt;button type="submit" class="btn btn-primary">Save&lt;/button>
            &lt;button type="button" class="btn btn-default" (click)="cancel()">Cancel&lt;/button>
        &lt;/div>
    `
})

export class CreateEventComponent{

    constructor(private router: Router){}

    cancel(){
        this.router.navigate(['/events']);
    }
}</code></pre>



<p>Step 2: routes.ts file</p>



<pre class="wp-block-code"><code>import { Routes } from '@angular/router'
import { CreateEventComponent } from './app/events/event-details/create-event.component';
import { EventDetailsComponent } from './app/events/event-details/event-details.component';
import { EventListComponent } from './app/events/event-list.component';

export const appRoutes:Routes = [
    { path: 'events/new', component: CreateEventComponent},
    { path: 'events', component: EventListComponent },
    { path: 'events/:id', component: EventDetailsComponent },    
    { path: '', redirectTo: '/events', pathMatch: 'full' }
]</code></pre>



<p>Step 3:  createEventComponent component  register  in app.module.ts file  </p>



<pre class="wp-block-code"><code>import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { EventsAppComponent } from './events-app.component';
import { EventListComponent } from './events/event-list.component';
import { EventThumbnailComponent } from './events/event-thumbnail.component';
import { NavBarComponent } from './nav/navbar-component';
import { EventService } from './events/shared/event.service';
import { ToastrService } from './common/toastr.service';
import { EventDetailsComponent } from './events/event-details/event-details.component';
import { RouterModule } from '@angular/router';
import { appRoutes } from 'src/routes';
import { CreateEventComponent } from './events/event-details/create-event.component';

@NgModule({
  declarations: [
    EventsAppComponent,
    EventListComponent,
    EventThumbnailComponent,
    NavBarComponent,
    EventDetailsComponent,
    CreateEventComponent
  ],
  imports: [
    BrowserModule,
    RouterModule.forRoot(appRoutes)
  ],
  providers: [EventService, ToastrService],
  bootstrap: [EventsAppComponent]
})
export class AppModule { }
</code></pre>



<p>Step 4: add router link in nav html file</p>



<pre class="wp-block-code"><code>&lt;div class="navbar navbar-default">
    &lt;div class="container-fluid">
      &lt;div class="navbar-header">
        &lt;a class="navbar-brand" >ngEvents&lt;/a>
      &lt;/div>
  
      &lt;div class="collapse navbar-collapse">
        &lt;ul class="nav navbar-nav">
          &lt;li>
            &lt;a [routerLink]="['/events']">All Events&lt;/a>
          &lt;/li>
          &lt;li>&lt;a [routerLink]="['/events/new']">Create Event&lt;/a>&lt;/li>
          &lt;li class="dropdown">
            &lt;a href="#" class="dropdown-toggle" data-toggle="dropdown" >
              Events
              &lt;span class="caret">&lt;/span>
            &lt;/a>
            &lt;ul class="dropdown-menu">
              &lt;li >
                &lt;a href="">Angular Connect&lt;/a>
              &lt;/li>
            &lt;/ul>
          &lt;/li>
        &lt;/ul>
        &lt;div class="navbar-header navbar-right">
          &lt;ul class="nav navbar-nav">
            &lt;li>
              &lt;a>Welcome John&lt;/a>
            &lt;/li>
          &lt;/ul>
        &lt;/div>
        &lt;form id="searchForm"  class="navbar-form navbar-right"  >
          &lt;div class="form-group">
            &lt;input type="text" class="form-control" placeholder="Search Sessions" >
          &lt;/div>
          &lt;button class="btn btn-default" >
            Search
          &lt;/button>
        &lt;/form>
      &lt;/div>
    &lt;/div>
  &lt;/div></code></pre>



<figure class="wp-block-image"><img loading="lazy" width="746" height="122" src="https://i1.wp.com/bipon.me/wp-content/uploads/2020/01/4.png?resize=746%2C122&#038;ssl=1" alt="" class="wp-image-292" srcset="https://i1.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/4.png?w=746&amp;ssl=1 746w, https://i1.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/4.png?resize=300%2C49&amp;ssl=1 300w" sizes="(max-width: 746px) 100vw, 746px" data-recalc-dims="1" /></figure><p>The post <a href="https://biponnotes.iglyphic.com/navigation-from-menu/">Navigation from menu</a> first appeared on <a href="https://biponnotes.iglyphic.com">Bipon's Diary</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://biponnotes.iglyphic.com/navigation-from-menu/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">291</post-id>	</item>
		<item>
		<title>Adding your first route</title>
		<link>https://biponnotes.iglyphic.com/adding-your-first-route-2/</link>
					<comments>https://biponnotes.iglyphic.com/adding-your-first-route-2/#respond</comments>
		
		<dc:creator><![CDATA[bipon68]]></dc:creator>
		<pubDate>Wed, 01 Jan 2020 17:12:10 +0000</pubDate>
				<category><![CDATA[Angular Router]]></category>
		<category><![CDATA[route]]></category>
		<category><![CDATA[router]]></category>
		<category><![CDATA[routes]]></category>
		<guid isPermaLink="false">https://bipon.me/?p=284</guid>

					<description><![CDATA[<p>Step 1: events-app.component.ts file Step 2: routes.ts file Step 3: app.module.ts file Register router for routing Step 4 : index.html Step 5: event-details.component.ts file Step 6: event.service.ts file Step 6: app.module.ts file Register event details file</p>
<p>The post <a href="https://biponnotes.iglyphic.com/adding-your-first-route-2/">Adding your first route</a> first appeared on <a href="https://biponnotes.iglyphic.com">Bipon's Diary</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Step 1: events-app.component.ts file</p>



<pre class="wp-block-code"><code>import { Component } from '@angular/core';

@Component({
  selector: 'events-app',
  template: `
    &lt;nav-bar>&lt;/nav-bar>
    &lt;router-outlet>&lt;/router-outlet>
    &lt;!-- &lt;events-list>&lt;/events-list> -->
  `
})
export class EventsAppComponent {
  title = 'ng-fundamentals';
}
</code></pre>



<figure class="wp-block-image"><img loading="lazy" width="873" height="110" src="https://i2.wp.com/bipon.me/wp-content/uploads/2020/01/1.png?resize=873%2C110&#038;ssl=1" alt="" class="wp-image-285" srcset="https://i0.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/1.png?w=873&amp;ssl=1 873w, https://i0.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/1.png?resize=300%2C38&amp;ssl=1 300w, https://i0.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/1.png?resize=768%2C97&amp;ssl=1 768w, https://i0.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/1.png?resize=750%2C95&amp;ssl=1 750w" sizes="(max-width: 873px) 100vw, 873px" data-recalc-dims="1" /></figure>



<p>Step 2: routes.ts file</p>



<pre class="wp-block-code"><code>import { Routes } from '@angular/router'
import { EventDetailsComponent } from './app/events/event-details/event-details.component';
import { EventListComponent } from './app/events/event-list.component';

export const appRoutes:Routes = [
    { path: 'events', component: EventListComponent },
    { path: 'events/:id', component: EventDetailsComponent },
    { path: '', redirectTo: '/events', pathMatch: 'full' }
]</code></pre>



<p>Step 3: app.module.ts file </p>



<p>Register router for routing </p>



<pre class="wp-block-code"><code>import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { EventsAppComponent } from './events-app.component';
import { EventListComponent } from './events/event-list.component';
import { EventThumbnailComponent } from './events/event-thumbnail.component';
import { NavBarComponent } from './nav/navbar-component';
import { EventService } from './events/shared/event.service';
import { ToastrService } from './common/toastr.service';
import { EventDetailsComponent } from './events/event-details/event-details.component';
import { RouterModule } from '@angular/router';
import { appRoutes } from 'src/routes';

@NgModule({
  declarations: [
    EventsAppComponent,
    EventListComponent,
    EventThumbnailComponent,
    NavBarComponent,
    EventDetailsComponent
  ],
  imports: [
    BrowserModule,
    RouterModule.forRoot(appRoutes)
  ],
  providers: [EventService, ToastrService],
  bootstrap: [EventsAppComponent]
})
export class AppModule { }
</code></pre>



<figure class="wp-block-image"><img loading="lazy" width="878" height="288" src="https://i0.wp.com/bipon.me/wp-content/uploads/2020/01/2.png?resize=878%2C288&#038;ssl=1" alt="" class="wp-image-286" srcset="https://i2.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/2.png?w=878&amp;ssl=1 878w, https://i2.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/2.png?resize=300%2C98&amp;ssl=1 300w, https://i2.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/2.png?resize=768%2C252&amp;ssl=1 768w, https://i2.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/2.png?resize=750%2C246&amp;ssl=1 750w" sizes="(max-width: 878px) 100vw, 878px" data-recalc-dims="1" /></figure>



<p>Step 4 : index.html</p>



<pre class="wp-block-code"><code>&lt;!doctype html>
&lt;html lang="en">
&lt;head>
  &lt;meta charset="utf-8">
  &lt;title>NgFundamentals&lt;/title>
  &lt;base href="/">

  &lt;meta name="viewport" content="width=device-width, initial-scale=1">
  &lt;link rel="icon" type="image/x-icon" href="favicon.ico">
&lt;/head>
&lt;body>
  &lt;div class="container">
    &lt;events-app>&lt;/events-app>
  &lt;/div>
  
&lt;/body>
&lt;/html>
</code></pre>



<figure class="wp-block-image"><img loading="lazy" width="883" height="123" src="https://i0.wp.com/bipon.me/wp-content/uploads/2020/01/3.png?resize=883%2C123&#038;ssl=1" alt="" class="wp-image-287" srcset="https://i1.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/3.png?w=883&amp;ssl=1 883w, https://i1.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/3.png?resize=300%2C42&amp;ssl=1 300w, https://i1.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/3.png?resize=768%2C107&amp;ssl=1 768w, https://i1.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/3.png?resize=750%2C104&amp;ssl=1 750w" sizes="(max-width: 883px) 100vw, 883px" data-recalc-dims="1" /><figcaption> added base url </figcaption></figure>



<p>Step 5: event-details.component.ts file</p>



<pre class="wp-block-code"><code>import { EventService } from './../shared/event.service';
import { Component } from '@angular/core';

@Component({
    templateUrl: './event-details.component.html',
    styles: [`
        .container {padding-left: 20px; padding-right: 20px;}
        .event-image{height: 100px}
    `]
})

export class EventDetailsComponent{

    event:any;

    constructor(private eventService: EventService){}

    ngOnInit(){
        this.event = this.eventService.getEvent(1);
    }
}</code></pre>



<p>Step 6: event.service.ts file</p>



<pre class="wp-block-code"><code>import { Injectable } from '@angular/core';

@Injectable()
export class EventService{
    getEvents(){
        return EVENTS;
    }

    getEvent(id:number){
      return EVENTS.find(event => event.id === id)
    }
}

const EVENTS = [
    {
      id: 1,
      name: 'Angular Connect',
      date: '9/26/2036',
      time: '10:00 am',
      price: 599.99,
      imageUrl: '/assets/images/angularconnect-shield.png',
      onlineUrl: 'http://google.com',
    },
    {
      id: 2,
      name: 'ng-nl',
      date: '4/15/2037',
      time: '9:00 am',
      price: 950.00,
      imageUrl: '/assets/images/ng-nl.png',
      onlineUrl: 'http://google.com',
      location: {
        address: 'The NG-NL Convention Center &amp; Scuba Shop',
        city: 'Amsterdam',
        country: 'Netherlands'
      },
    {
      id: 3,
      name: 'ng-conf 2037',
      date: '5/4/2037',
      time: '10:00 am',
      price: 759.00,
      imageUrl: '/assets/images/ng-conf.png',
      location: {
        address: 'The Palatial America Hotel',
        city: 'Salt Lake City',
        country: 'USA'
      },
    {
      id: 4,
      name: 'UN Angular Summit',
      date: '6/10/2037',
      time: '8:00 am',
      price: 800.00,
      imageUrl: '/assets/images/basic-shield.png',
      location: {
        address: 'The UN Angular Center',
        city: 'New York',
        country: 'USA'
      },
    {
      id: 5,
      name: 'ng-vegas',
      date: '2/10/2037',
      time: '9:00 am',
      price: 400.00,
      imageUrl: '/assets/images/ng-vegas.png',
      location: {
        address: 'The Excalibur',
        city: 'Las Vegas',
        country: 'USA'
      }
    }
  ]</code></pre>



<p>Step 6: app.module.ts file</p>



<p>Register event details file</p>



<pre class="wp-block-code"><code>import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { EventsAppComponent } from './events-app.component';
import { EventListComponent } from './events/event-list.component';
import { EventThumbnailComponent } from './events/event-thumbnail.component';
import { NavBarComponent } from './nav/navbar-component';
import { EventService } from './events/shared/event.service';
import { ToastrService } from './common/toastr.service';
import { EventDetailsComponent } from './events/event-details/event-details.component';
import { RouterModule } from '@angular/router';
import { appRoutes } from 'src/routes';

@NgModule({
  declarations: [
    EventsAppComponent,
    EventListComponent,
    EventThumbnailComponent,
    NavBarComponent,
    EventDetailsComponent
  ],
  imports: [
    BrowserModule,
    RouterModule.forRoot(appRoutes)
  ],
  providers: [EventService, ToastrService],
  bootstrap: [EventsAppComponent]
})
export class AppModule { }
</code></pre><p>The post <a href="https://biponnotes.iglyphic.com/adding-your-first-route-2/">Adding your first route</a> first appeared on <a href="https://biponnotes.iglyphic.com">Bipon's Diary</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://biponnotes.iglyphic.com/adding-your-first-route-2/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">284</post-id>	</item>
		<item>
		<title>Linking routes and accessing routes parameters</title>
		<link>https://biponnotes.iglyphic.com/linking-routes-and-accessing-routes-parameters/</link>
					<comments>https://biponnotes.iglyphic.com/linking-routes-and-accessing-routes-parameters/#respond</comments>
		
		<dc:creator><![CDATA[bipon68]]></dc:creator>
		<pubDate>Wed, 01 Jan 2020 16:52:01 +0000</pubDate>
				<category><![CDATA[Angular Router]]></category>
		<category><![CDATA[route]]></category>
		<category><![CDATA[router]]></category>
		<category><![CDATA[routes]]></category>
		<guid isPermaLink="false">https://bipon.me/?p=277</guid>

					<description><![CDATA[<p>Step 1: event-details.component.ts file Step 2: event-thumbnail.component.ts file Step 3: nav-bar.component.html file</p>
<p>The post <a href="https://biponnotes.iglyphic.com/linking-routes-and-accessing-routes-parameters/">Linking routes and accessing routes parameters</a> first appeared on <a href="https://biponnotes.iglyphic.com">Bipon's Diary</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Step 1: event-details.component.ts file</p>



<pre class="wp-block-code"><code>import { EventService } from './../shared/event.service';
import { Component } from '@angular/core';
import { ActivatedRoute } from '@angular/router';

@Component({
    templateUrl: './event-details.component.html',
    styles: [`
        .container {padding-left: 20px; padding-right: 20px;}
        .event-image{height: 100px}
    `]
})

export class EventDetailsComponent{

    event:any;

    constructor(private eventService: EventService, private route:ActivatedRoute){}

    ngOnInit(){
        this.event = this.eventService.getEvent(
            +this.route.snapshot.params['id']
        );
    }
}</code></pre>



<figure class="wp-block-image"><img loading="lazy" width="912" height="114" src="https://i0.wp.com/bipon.me/wp-content/uploads/2020/01/router-link2.png?resize=912%2C114&#038;ssl=1" alt="" class="wp-image-280" srcset="https://i1.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/router-link2.png?w=912&amp;ssl=1 912w, https://i1.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/router-link2.png?resize=300%2C38&amp;ssl=1 300w, https://i1.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/router-link2.png?resize=768%2C96&amp;ssl=1 768w, https://i1.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/router-link2.png?resize=750%2C94&amp;ssl=1 750w" sizes="(max-width: 912px) 100vw, 912px" data-recalc-dims="1" /></figure>



<p>Step 2: event-thumbnail.component.ts file</p>



<pre class="wp-block-code"><code>import { Component, Input, Output, EventEmitter } from '@angular/core';

@Component({
    selector: 'event-thumbnail',
    template: `        
        &lt;div [routerLink]="['/events', event.id]"
            class="well thumbnail">
            &lt;h2>{{event?.name}}&lt;/h2>
            &lt;div>Date: {{event?.date}}&lt;/div>
            &lt;div [ngStyle]="getStartTimeStyle()" 
            [ngSwitch]="event?.time">
                Time: {{event?.time}}
                &lt;span *ngSwitchCase="'8:00 am'">(Early Start)&lt;/span>
                &lt;span *ngSwitchCase="'10:00 am'">(Late Start)&lt;/span>
                &lt;span *ngSwitchDefault>(Normal Start)&lt;/span>
            &lt;/div>
            &lt;div>price: \${{event?.price}}&lt;/div>
            &lt;div *ngIf="event?.location">
                &lt;span>Location: {{event?.location?.address}}&lt;/span>
                &lt;span> &lt;/span>
                &lt;span>{{event?.location?.city}}, {{event?.location?.country}}&lt;/span>
            &lt;/div>
            &lt;div *ngIf="event?.onlineUrl">
                Online Url: {{event?.onlineUrl}}
            &lt;/div>
            &lt;!-- &lt;button class="btn btn-primary" (click)="handleClickMe()"> Click Me&lt;/button> -->
        &lt;/div>

    `,
    styles : [`
        .green{color: green !important}
        .bold{font-weight: bold;}
        .thumbnail{min-height: 210px;}
    `]
})
export class EventThumbnailComponent{
    @Input() event: any;
    @Output() eventClick = new EventEmitter;
    getStartTimeClass(){
        if(this.event &amp;&amp; this.event.time === '8:00 am')
            return ['green', 'bold']
        return []
        // if(this.event &amp;&amp; this.event.time === '8:00 am')
        //     return 'green bold'
        // return ''
        //const isEarlyStart = this.event &amp;&amp; this.event.time === '8:00 am'
        //return {green: isEarlyStart, bold: isEarlyStart}
    }
    getStartTimeStyle():any{
        if(this.event &amp;&amp; this.event.time === '8:00 am')
            return {color: '#003300', 'font-weight': 'bold'}
        return {}
    }
    handleClickMe(){
        // this.eventClick.emit('Foo');
        this.eventClick.emit(this.event.name);
        //console.log('Clicked');
    }
}</code></pre>



<figure class="wp-block-image"><img loading="lazy" width="872" height="488" src="https://i0.wp.com/bipon.me/wp-content/uploads/2020/01/router-link1.png?resize=872%2C488&#038;ssl=1" alt="" class="wp-image-278" srcset="https://i0.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/router-link1.png?w=872&amp;ssl=1 872w, https://i0.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/router-link1.png?resize=300%2C168&amp;ssl=1 300w, https://i0.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/router-link1.png?resize=768%2C430&amp;ssl=1 768w, https://i0.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/router-link1.png?resize=750%2C420&amp;ssl=1 750w" sizes="(max-width: 872px) 100vw, 872px" data-recalc-dims="1" /></figure>



<p>Step 3: nav-bar.component.html file</p>



<pre class="wp-block-code"><code>&lt;div class="navbar navbar-default">
    &lt;div class="container-fluid">
      &lt;div class="navbar-header">
        &lt;a class="navbar-brand" >ngEvents&lt;/a>
      &lt;/div>
  
      &lt;div class="collapse navbar-collapse">
        &lt;ul class="nav navbar-nav">
          &lt;li>
            &lt;a [routerLink]="['/events']">All Events&lt;/a>
          &lt;/li>
          &lt;li>&lt;a href="">Create Event&lt;/a>&lt;/li>
          &lt;li class="dropdown">
            &lt;a href="#" class="dropdown-toggle" data-toggle="dropdown" >
              Events
              &lt;span class="caret">&lt;/span>
            &lt;/a>
            &lt;ul class="dropdown-menu">
              &lt;li >
                &lt;a href="">Angular Connect&lt;/a>
              &lt;/li>
            &lt;/ul>
          &lt;/li>
        &lt;/ul>
        &lt;div class="navbar-header navbar-right">
          &lt;ul class="nav navbar-nav">
            &lt;li>
              &lt;a>Welcome John&lt;/a>
            &lt;/li>
          &lt;/ul>
        &lt;/div>
        &lt;form id="searchForm"  class="navbar-form navbar-right"  >
          &lt;div class="form-group">
            &lt;input type="text" class="form-control" placeholder="Search Sessions" >
          &lt;/div>
          &lt;button class="btn btn-default" >
            Search
          &lt;/button>
        &lt;/form>
      &lt;/div>
    &lt;/div>
  &lt;/div></code></pre>



<figure class="wp-block-image"><img loading="lazy" width="787" height="120" src="https://i2.wp.com/bipon.me/wp-content/uploads/2020/01/router-link3-1.png?resize=787%2C120&#038;ssl=1" alt="" class="wp-image-281" srcset="https://i0.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/router-link3-1.png?w=787&amp;ssl=1 787w, https://i0.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/router-link3-1.png?resize=300%2C46&amp;ssl=1 300w, https://i0.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/router-link3-1.png?resize=768%2C117&amp;ssl=1 768w, https://i0.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/router-link3-1.png?resize=750%2C114&amp;ssl=1 750w" sizes="(max-width: 787px) 100vw, 787px" data-recalc-dims="1" /></figure><p>The post <a href="https://biponnotes.iglyphic.com/linking-routes-and-accessing-routes-parameters/">Linking routes and accessing routes parameters</a> first appeared on <a href="https://biponnotes.iglyphic.com">Bipon's Diary</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://biponnotes.iglyphic.com/linking-routes-and-accessing-routes-parameters/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">277</post-id>	</item>
		<item>
		<title>Adding your first route</title>
		<link>https://biponnotes.iglyphic.com/adding-your-first-route/</link>
					<comments>https://biponnotes.iglyphic.com/adding-your-first-route/#respond</comments>
		
		<dc:creator><![CDATA[bipon68]]></dc:creator>
		<pubDate>Mon, 30 Dec 2019 20:19:37 +0000</pubDate>
				<category><![CDATA[Angular]]></category>
		<category><![CDATA[angular]]></category>
		<category><![CDATA[router]]></category>
		<guid isPermaLink="false">https://bipon.me/?p=275</guid>

					<description><![CDATA[<p>Step 1: events-app.component.ts file Step 2: routes.ts file Step 3: app.module.ts file Step 4: index.html file. Added our base tag</p>
<p>The post <a href="https://biponnotes.iglyphic.com/adding-your-first-route/">Adding your first route</a> first appeared on <a href="https://biponnotes.iglyphic.com">Bipon's Diary</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Step 1: events-app.component.ts file</p>



<pre class="wp-block-code"><code>import { Component } from '@angular/core';

@Component({
  selector: 'events-app',
  template: `
    &lt;nav-bar>&lt;/nav-bar>
    &lt;router-outlet>&lt;/router-outlet>
    &lt;!-- &lt;events-list>&lt;/events-list> -->
  `
})
export class EventsAppComponent {
  title = 'ng-fundamentals';
}</code></pre>



<p>Step 2: routes.ts file</p>



<pre class="wp-block-code"><code>import { Routes } from '@angular/router'
import { EventDetailsComponent } from './app/events/event-details/event-details.component';
import { EventListComponent } from './app/events/event-list.component';

export const appRoutes:Routes = [
    { path: 'events', component: EventListComponent },
    { path: 'events/:id', component: EventDetailsComponent },
    { path: '', redirectTo: '/events', pathMatch: 'full' }
]</code></pre>



<p>Step 3: app.module.ts file</p>



<pre class="wp-block-code"><code>import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { EventsAppComponent } from './events-app.component';
import { EventListComponent } from './events/event-list.component';
import { EventThumbnailComponent } from './events/event-thumbnail.component';
import { NavBarComponent } from './nav/navbar-component';
import { EventService } from './events/shared/event.service';
import { ToastrService } from './common/toastr.service';
import { EventDetailsComponent } from './events/event-details/event-details.component';
import { RouterModule } from '@angular/router';
import { appRoutes } from 'src/routes';

@NgModule({
  declarations: [
    EventsAppComponent,
    EventListComponent,
    EventThumbnailComponent,
    NavBarComponent,
    EventDetailsComponent
  ],
  imports: [
    BrowserModule,
    RouterModule.forRoot(appRoutes)
  ],
  providers: [EventService, ToastrService],
  bootstrap: [EventsAppComponent]
})
export class AppModule { }
</code></pre>



<p>Step 4: index.html file. Added our base tag</p>



<pre class="wp-block-code"><code>&lt;!doctype html>
&lt;html lang="en">
&lt;head>
  &lt;meta charset="utf-8">
  &lt;title>NgFundamentals&lt;/title>
  &lt;base href="/">

  &lt;meta name="viewport" content="width=device-width, initial-scale=1">
  &lt;link rel="icon" type="image/x-icon" href="favicon.ico">
&lt;/head>
&lt;body>
  &lt;div class="container">
    &lt;events-app>&lt;/events-app>
  &lt;/div>
  
&lt;/body>
&lt;/html></code></pre><p>The post <a href="https://biponnotes.iglyphic.com/adding-your-first-route/">Adding your first route</a> first appeared on <a href="https://biponnotes.iglyphic.com">Bipon's Diary</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://biponnotes.iglyphic.com/adding-your-first-route/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">275</post-id>	</item>
	</channel>
</rss>
