YogeshChauhan . com

How to add AppRoutingModule in Angular application using command line?

in Angular on October 3, 2020

Add the AppRoutingModule

In Angular, the best practice is to load and configure the router in a separate, top-level module that is dedicated to routing and imported by the root AppModule.

By convention, the module class name is AppRoutingModule and it belongs in the app-routing.module.ts in the src/app folder.

Use the CLI to generate it.

ng generate module app-routing --flat --module=app


flat puts the file in src/app instead of its own folder.

module=app tells the CLI to register it in the imports array of the AppModule.

The generated file looks like this:

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

  imports: [
  declarations: []
export class AppRoutingModule { }

Credit: Angular.io


Most Read

#1 How to check if radio button is checked or not using JavaScript? #2 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #3 How to add Read More Read Less Button using JavaScript? #4 How to uninstall Cocoapods from the Mac OS? #5 How to Use SQL MAX() Function with Dates? #6 PHP Login System using PDO Part 1: Create User Registration Page

Recently Posted

Jun 16 What are Stored Procedures for SQL Server? Jun 16 What are Class Constants in PHP? Jun 15 A short basic guide on states in React Jun 15 How to define constants in PHP? Jun 15 How to define visibility for a property in PHP? Jun 15 How to use @if and @else in SCSS?

You might also like these

How to add a ribbon on top of a container using CSS?CSSWhat is the difference between float and double?MiscHow to Draw a Circle in HTML5 Using Canvas Tag?HTMLHow to create HTML elements with ID and class using JavaScript?HTMLWhat’s a Web Storage API in JavaScript?JavaScriptHow different is Handling Events in React vs HTML DOM?ReactSolution to “TypeError: ‘x’ is not iterable” in Angular 9Angular@forward rule in SCSS (Sass)SCSSHow to make flexbox items of the same size?CSSSelf-Driving and Intelligent NetworksMiscClasses in JavaScript: The BasicsJavaScriptHow to define variables in SCSS (Sass)?SCSS