如何在Angle CLI 6+中添加组件默认值 [英] How do I add component defaults in angular cli 6+
问题描述
在旧的角度cli中,有一个名为defaults
的键:
In the old angular cli there was a key called defaults
:
"defaults": {
"schematics": {
"collection": "@nrwl/schematics",
"postGenerate": "npm run format",
"newProject": [
"app",
"lib"
]
},
"styleExt": "scss",
"component": {
"changeDetection": "OnPush"
}
}
此属性不再存在.如何在角度cli 6+中推送时添加component/changeDetection?此外,还有可以添加的组件属性列表吗?
This property no longer exsists. How do I add component/changeDetection on push in angular cli 6+? moreover is there a list of component properties I can add?
推荐答案
我对旧的CLI不太熟悉.这些属性是配置为全局CLI设置还是每个项目的设置?
I'm not as familiar with the old CLI. Were those properties configured as global CLI settings, or a per-project setting?
在新的Angular CLI中,您可以通过将schematics
对象更新为以下内容来复制angular.json
文件中的每个项目设置:
In the new Angular CLI, you can replicate per-project settings in the angular.json
file by updating the schematics
object to the following:
"projects": {
"my-project": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"prefix": "app",
"schematics": {
"@schematics/angular:component": {
"changeDetection": "OnPush"
}
},
"projects": {
"my-project": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"prefix": "app",
"schematics": {
"@schematics/angular:component": {
"changeDetection": "OnPush"
}
},
这篇关于如何在Angle CLI 6+中添加组件默认值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!