How to put a component inside another component in Angular2?

后端 未结 3 1464
猫巷女王i
猫巷女王i 2021-01-31 02:18

I\'m new at Angular and I\'m still trying to understand it. I\'ve followed the course on the Microsoft Virtual Academy and it was great, but I found a little discrepancy between

3条回答
  •  猫巷女王i
    2021-01-31 02:56

    You don't put a component in directives

    You register it in @NgModule declarations:

    @NgModule({
      imports: [ BrowserModule ],
      declarations: [ App , MyChildComponent ],
      bootstrap: [ App ]
    })
    

    and then You just put it in the Parent's Template HTML as :

    That's it.

提交回复
热议问题