美文网首页
angular ng-content

angular ng-content

作者: 会飞得鼠 | 来源:发表于2019-03-28 01:10 被阅读0次

投影 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>

相关文章

网友评论

      本文标题:angular ng-content

      本文链接:https://www.haomeiwen.com/subject/lvtfbqtx.html