简体   繁体   中英

Angular Schematics Skip "implements OnInit"

I've found plenty about how to setup my schematic file to skip certain things (like the spec file) when creating a component using ng generate but what I can't find anywhere is how to not include the implements OnInit when I use ng generate component .

I've looked everwhere. Anyone have an idea?

到今天为止,还没有这个选项

There is no official way to do this, but there is a trick that allows you to generate new components without implements OnInit or Constructor() .

You just have to mismatch the node version. The Constructor and implements OnInit is not generated when using node 16.17.0 with Angular v15 in Windows, but it works fine in Linux Ubuntu. So you'll have to figure it out for yourself by changing only the minor version of the node.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM