Yogesh Chauhan's Blog

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 PHP Login System using PDO Part 1: Create User Registration Page #6 How to Use SQL MAX() Function with Dates?

Recently Posted

#Aug 15 Is PHP still good for back-end programming? #Aug 10 How to create a multisite network in WordPress? #Aug 3 How to create a circle that follows a cursor using JavaScript and CSS? #Aug 3 How to make a curtain slider using jQuery and CSS? #Aug 2 How to progressively load images and add a blurry placeholder? #Aug 1 How to create a placeholder loader (throbber) using CSS?
You might also like these
How to create a Progress Bar using JavaScript?JavaScriptGap in Flex?CSSHow to change style of nth-child using jQuery?jQueryLearn to Implement Estimated Reading Time using PHP Part 2: Final Implementation with Source CodePHPHow to Clone Objects in PHP?MiscellaneousQuick Introduction to 11 Array Iteration Methods in JavaScriptJavaScriptHow to disable scrolling on html body on menu click using JavaScript?JavaScriptCheck if any column has NULL values in PostgresPostgresHow to calculate elapsed time in JavaScript?JavaScriptHow to merge arrays in JavaScript?JavaScriptHow to remove a specific item from an array in JavaScript?JavaScriptHow to get user’s Browser and Operating Systems information using PHP?PHP