你不应该用任何东西代替???。
@ContentChild
装饰器将确保 Angular 使用相应的内容子项填充类中的字段。
在某些项目中,您可以满足用于明确且干净的模板标记的辅助指令。在你的情况下,它看起来像这样:
@Directive({selector: '[lookupContent]'})
class LookupContentDirective{
constructor(public template: TemplateRef)
}
....
class AppLookupComponent {
@ContentChild(LookupContentDirective) content: LookupContentDirective;
...
// app-lookup.component.html
<div *ngTemplateOutlet="content.template; context: context"></div>
...
// usage
<app-lookup>
<li *lookupContent>li will be a template</li>
</app-lookup>