LemonMart will be a mid-sized line-of-business application with over 90 code files. We will start our journey by creating a new Angular app with routing and Angular Material configured from the get go.
With the Router-first approach, we will want to enable routing early on in our application:
- You can create the new application with routing already configured by executing this command:
Ensure that @angular/cli
is not installed globally, or you may run into errors:
$ npx @angular/cli new lemon-mart --routing
- A new
AppRoutingModule
file has been created for us:
src/app/app-routing.modules.ts
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
const routes: Routes = [];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }
We will be defining routes inside the routes array. Note that routes array is passed in to be configured as the root routes...