How to extend / inherit components?

后端 未结 12 834
萌比男神i
萌比男神i 2020-12-02 04:11

I would like to create extensions for some components already deployed in Angular 2, without having to rewrite them almost completely, as the base component could undergo ch

12条回答
  •  旧时难觅i
    2020-12-02 04:55

    update

    Component inheritance is supported since 2.3.0-rc.0

    original

    So far, the most convenient for me is to keep template & styles into separate *html & *.css files and specify those through templateUrl and styleUrls, so it's easy reusable.

    @Component {
        selector: 'my-panel',
        templateUrl: 'app/components/panel.html', 
        styleUrls: ['app/components/panel.css']
    }
    export class MyPanelComponent extends BasePanelComponent
    

提交回复
热议问题