我想弄清楚是否可以使用cli命令更改应用程序配置值(如前缀)?
I.e。:
应用程序设置的“前缀”值默认设置为“app”。我在步骤1中创建应用程序时没有更改它。现在,在步骤2中创建新组件后,我意识到前缀“app”并不是那么好。
我的问题是,是否有一个cli命令可以更改应用程序配置中的前缀,和在代码中也是如此?
答案 0 :(得分:1)
您可以使用ng set apps.0.prefix='two'
更改前缀。由您来重构以前的代码以遵循新的前缀。大多数编辑都可以为您提供帮助。
根据我的经验,这不会更新tslint.json
中的值,因此您也希望更改其中的值。
对于tslint.json
,您可以设置组件和指令规则:
"directive-selector": [true, "attribute", "app", "camelCase"],
"component-selector": [true, "element", "app", "kebab-case"],
如果要使用多个前缀,可以在这样的数组中指定它们(example from here):
//RULES: [ENABLED, "attribute" | "element", "selectorPrefix" | ["listOfPrefixes"], "camelCase" | "kebab-case"]
"directive-selector": [true, "attribute", ["dir-prefix1", "dir-prefix2"], "camelCase"],
"component-selector": [true, "element", ["cmp-prefix1", "cmp-prefix2"], "kebab-case"],
希望这有帮助。