Karellism

1. Creating Routes

May 4th, 2019
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!

ng g module routing --spec false --module app

in routing.module.ts

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { Routes, RouterModule } from '@angular/router';
import { HomeComponent } from '../home/home.component';

const routes: Routes = [
{ path: 'home', component: HomeComponent},
{ path: '', redirectTo: '/home', pathMatch: 'full' }

];

@NgModule({
imports: [
CommonModule,
RouterModule.forRoot(routes)
],
exports: [
RouterModule
],
declarations: []
})
export class RoutingModule { }

=======================
app.component.html

<app-layout>
<main>
<router-outlet></router-outlet>
</main>
</app-layout>

Add Comment
Please, Sign In to add comment