Building a wrapper directive (wrap some content / component) in angular2

前端 未结 2 1905
轮回少年
轮回少年 2020-12-31 06:30

I\'m pretty new building directives with Angular2. What I want is to create a popup directive that will wrap the content with some css classes.

Content

2条回答
  •  再見小時候
    2020-12-31 07:02

    You can achieve this with a component attribute selector and Angular 2 Content Projection

    @Component({
      selector: 'my-app',
      template: `
        

    Header

    Content to be placed here.
    ` }) export class AppComponent {} @Component({ selector: '[myWrapper]', template: `
    ` }) export class MyComponent { }

提交回复
热议问题