角分量内的角分量? ` ] `

问题描述 投票:2回答:1

我已经尝试过使用ng-templateng-container,但是我不知道如何在组件内部包括组件...

import { Component } from '@angular/core';


@Component({
  selector: 'hello',
  //  template: `<h1>Hello</h1><div>I am in a div<ng-container></ng-container>; now this is end</div>`,
  template: `<h1>Hello</h1><div>I am in a div<ng-template></ng-template>; now this is end</div>`,
  styles: [`h1 { font-family: Lato; }`]
})
export class HelloComponent  {}


@Component({
  selector: 'intestines',
  template: 'Eww',
  styles: []
})
export class IntestinesComponent  {}


@Component({
  selector: 'my-app',
  template: `<hello><intestines></intestines></hello>`,
  styles: [ 'p { font-family: Lato; }' ]
})
export class AppComponent  {}

https://stackblitz.com/edit/angular-2b2yl3

我已经尝试使用ng-template和ng-container,但是我不知道如何在组件中包括组件……从'@ angular / core'导入{Component}; @Component({选择器:'hello',...

angular angular-components angular-template
1个回答
1
投票

使用ng-content

© www.soinside.com 2019 - 2024. All rights reserved.