Create component to specific module with Angular-CLI

后端 未结 26 1667
既然无缘
既然无缘 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:18


    Make a module, service and component in particular module

    Basic:
    
        ng g module chat     
        ng g service chat/chat -m chat
        ng g component chat/chat-dialog -m chat
    
        In chat.module.ts:
            exports: [ChatDialogComponent],
            providers: [ChatService]
    
        In app.module.ts:
    
            imports: [
                BrowserModule,
                ChatModule
            ]
    
        Now in app.component.html:
            
    
    
    LAZY LOADING:
        ng g module pages --module app.module --route pages
    
            CREATE src/app/pages/pages-routing.module.ts (340 bytes)
            CREATE src/app/pages/pages.module.ts (342 bytes)
            CREATE src/app/pages/pages.component.css (0 bytes)
            CREATE src/app/pages/pages.component.html (20 bytes)
            CREATE src/app/pages/pages.component.spec.ts (621 bytes)
            CREATE src/app/pages/pages.component.ts (271 bytes)
            UPDATE src/app/app-routing.module.ts (8611 bytes)       
    
        ng g module pages/forms --module pages/pages.module --route forms
    
            CREATE src/app/forms/forms-routing.module.ts (340 bytes)
            CREATE src/app/forms/forms.module.ts (342 bytes)
            CREATE src/app/forms/forms.component.css (0 bytes)
            CREATE src/app/forms/forms.component.html (20 bytes)
            CREATE src/app/forms/forms.component.spec.ts (621 bytes)
            CREATE src/app/forms/forms.component.ts (271 bytes)
            UPDATE src/app/pages/pages-routing.module.ts (437 bytes)
    

提交回复
热议问题