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

Where

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';

@NgModule({
  imports: [
    CommonModule
  ],
  declarations: []
})
export class AppRoutingModule { }

Credit: Angular.io


Most Read

#1 How to check if radio button is checked or not using JavaScript? #2 How to add Read More Read Less Button using JavaScript? #3 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #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

#Jan 17 4 advanced ways to search Colleague #Jan 16 Colleague UI Basics: The Search Area #Jan 16 Colleague UI Basics: The Context Area #Jan 16 Colleague UI Basics: Accessing the user interface #Jan 14 How to display a student’s individual transcript in Colleague? #Jan 11 How to install PuTTY on a MacOS?
You might also like these
What is the best way to add JavaScript Code into HTML?HTMLEverything you need to know about ANY, SOME and ALL Operators in PostgresPostgresThe difference between Class declarations and Class expressions in JavaScriptJavaScriptHow to set the permissions on all files and folders in Mac?MiscellaneousIntroduction to components and templates Part 1: Component MetadataAngularFULL OUTER JOIN in PostgresPostgresAdd animation to your skills bar using CSSCSSHow Do You Make a Private VPN?MiscellaneousLearn to Make a Simple Contact Us Form using PHP and PDO-MySQLPHPHow to avoid element shift on border change while hovering in CSS?CSSLearn to create profile card using HTML and CSSCSSThe Lending Club Analysis using Logistic Regression and Random Forest in RStudioMiscellaneous