YogeshChauhan.com
How to add AppRoutingModule in Angular application using command line?
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

dreamhost

Leave a Reply

Most Read

#1 How to check if radio button is checked or not using JavaScript? #2 How to set opacity or transparency using CSS? #3 Pagination in CSS with multiple examples #4 How to make HTML form interactive and using CSS? #5 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #6 How to uninstall Cocoapods from the Mac OS?

Recently Posted

Mar 2 How to zoom an element on hover using CSS? Mar 2 the box-sizing property in CSS Mar 2 WordPress: How to access first and random row values from a repeater field in ACF? Mar 1 The basics of CSS Box model Feb 27 WordPress: How to display slider repeater fields in ACF? Feb 26 Simple Page Hit Counter in PHP

You might also like these

How to use HTML Quotation and Citation?HTMLHow to check if the page is the home page in WordPress?WordPressWhat is Hadoop and Hadoop Ecosystem?MiscSELF JOIN in PostgresPostgresHow to Use password_hash and password_verify to Secure Your User’s Data (Especially Passwords)?PHPWhat happens when we add Numbers and Strings in JavaScript?JavaScriptHow to create a Progress Bar using JavaScript?JavaScriptWhat are components in Angular?AngularCommon Table Expressions (CTE) in PostgreSQLPostgresAggregate Functions Examples in Postgres for BeginnersPostgresList of all Pseudo Elements in CSSCSSPHP arrays for US states’ full names and abbreviationsPHP