投影 ng-content
修改映射组件样式
@Component({
selector:'',
template:`
<app-projection>
//放入投影组件
<custmoizeComponent><custmoizeComponent>
</app-projection>
`
})
export class Projection{
//获取投影进来的组件,@ContentChildren获取的是集合
@ContentChild(custmoizeComponent) c:custmoizeComponent;
}
@Component({
selector:'app-projection',
template:`
<ng-content select="custmoizeComponent"></ng-content>
`
})
export class Projection{
//获取投影进来的组件,@ContentChildren获取的是集合
@ContentChild(custmoizeComponent) c:custmoizeComponent;
}
//包裹在结构指令中可以是ngProjectAs绑定
<ng-container ngProjectAs=""> </ng-container>