Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does --routing-scope stands for in Angular CLI

In angular CLI when creating module we can add --routing-scope as a parameter.

ng g m dashboard --routing-scope something-here --routing

when using this command I get error:

Schematic input does not validate against the 
Schema: {"routingScope":"dashboard","routing":false,"spec":true,"flat":false,"commonModule":true}
Errors: Data path ".routingScope" should be equal to one of the allowed values.

But what are the allowed values?

This parameter is not described in the docs.

like image 965
Tukkan Avatar asked Jul 02 '18 13:07

Tukkan


Video Answer


1 Answers

After some digging, I found this: schema.json, the schema.json for the CLI. Lots of good stuff in this.

According to this, the valid values for --routing-scope are either Child, or Root. Casing matters. The default is Child.

An odd thing is, the code that gets generated looks exactly the same no matter what value I use. They both look like what is below after running ng g m testing --routing-scope Child or ng g m testing --routing-scope Root

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

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

Further digging shows that the value is used when code is generated to build the forRoot or forChild function in module imports.

like image 69
R. Richards Avatar answered Sep 24 '22 10:09

R. Richards