在Angular CLI中--routing scope代表什么
在angular CLI中,当创建模块时,我们可以添加--routing scope作为参数在Angular CLI中--routing scope代表什么,angular,angular-cli,angular-cli-v6,Angular,Angular Cli,Angular Cli V6,在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,"com
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.
但允许的值是什么
文档中没有描述此参数。经过一些挖掘,我找到了以下内容:,CLI的schema.json。这里面有很多好东西 据此,
--路由范围
的有效值要么是子
,要么是根
。套管问题。默认值为Child
奇怪的是,无论我使用什么值,生成的代码看起来都完全一样。在运行nggm测试--路由作用域子项
或nggm测试--路由作用域根
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
@NgModule({
imports: [
CommonModule
],
declarations: []
})
export class TestingModule { }
在模块
imports
中生成代码以构建forRoot
或forChild
函数时,进一步挖掘该值的用途,可以查看docs@Li357这一点在报告中没有描述docs@Tukkan,此处提到:@crueengine是,但“生成路由的范围。”都是我写的东西,我可以从参数名推断出什么,但还不完全清楚。它是主根配置中的根的名称还是其他名称?我尝试了多个值和组合,所有这些值和组合都返回上述错误。Ok。因此,基本上,在使用ng new projectName--routing
时,以及在使用--routing
参数创建子模块时,使用forRoot,子模块是默认值,这完全有意义。谢谢