【问题标题】:What does --routing-scope stands for in Angular CLI--routing-scope 在 Angular CLI 中代表什么
【发布时间】:2018-12-10 18:40:54
【问题描述】:

在创建模块时,我们可以在 Angular CLI 中添加 --routing-scope 作为参数。

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

使用此命令时出现错误:

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.

但是允许的值是多少?

文档中没有描述这个参数。

【问题讨论】:

  • 也许可以查看文档
  • @Li357 文档中没有描述
  • @Tukkan,这里提到了他们:github.com/angular/angular-cli/wiki/generate-module
  • @CruelEngine 是但“生成路由的范围。”是写的所有内容以及我可以从参数名称中推断出的内容,但仍不完全清楚。它是主要生根配置中的根名称还是不同的名称?我尝试了多个值和组合,它们都返回上述错误。

标签: angular angular-cli angular-cli-v6


【解决方案1】:

经过一番挖掘,我发现了这个:schema.json,CLI 的 schema.json。这里面有很多好东西。

据此,--routing-scope 的有效值为ChildRoot。外壳很重要。默认为Child

奇怪的是,无论我使用什么值,生成的代码看起来都完全相同。运行 ng g m testing --routing-scope Childng g m testing --routing-scope Root 后,它们看起来都如下所示

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

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

进一步挖掘shows,该值用于生成代码以在模块imports 中构建forRootforChild 函数。

【讨论】:

  • 好的。所以基本上在使用ng new projectName --routing 和使用--routing 参数创建子模块时无论如何都会使用forRoot,Child 是默认值,这完全有道理。谢谢!
猜你喜欢
  • 2022-12-06
  • 2016-06-04
  • 2017-06-28
  • 2015-03-19
  • 1970-01-01
  • 1970-01-01
  • 2023-03-23
  • 1970-01-01
  • 2016-03-21
相关资源
最近更新 更多