Create component to specific module with Angular-CLI

后端 未结 26 1669
既然无缘
既然无缘 2021-01-29 19:46

I\'m starting to use angular-cli and I\'ve already read a lot to find an answer about what I want to do...no success, so I came here.

Is there a way to create a componen

26条回答
  •  南笙
    南笙 (楼主)
    2021-01-29 20:20

    1.- Create your feature module as usual.

    ng generate module dirlevel1/module-name
    

    2.- You can specify the ROOT PATH of your project in --module ( only in --module, (/) root points to your PROJECT ROOT and IS NOT THE SYSTEM ROOT!!!)

    ng generate component dirlevel1/component-name --module /src/app/dirlevel1/module-name.module.ts
    

    Real Example:

    ng generate module stripe/payment-methods-list
    
    ng generate component stripe/payment-methods-list --module=/src/app/stripe/payment-methods-list/payment-methods-list.module.ts 
    

    Output:

    CREATE src/app/stripe/payment-methods-list/payment-methods-list.component.scss (0 bytes)
    CREATE src/app/stripe/payment-methods-list/payment-methods-list.component.html (39 bytes)
    CREATE src/app/stripe/payment-methods-list/payment-methods-list.component.spec.ts (768 bytes)
    CREATE src/app/stripe/payment-methods-list/payment-methods-list.component.ts (322 bytes)
    UPDATE src/app/stripe/payment-methods-list/payment-methods-list.module.ts (311 bytes)
    [OK] Generated component!
    

    Tested with Angular CLI: 9.1.4

提交回复
热议问题