How do you inherit the template from a parent component in angular 4?

前端 未结 2 810
长情又很酷
长情又很酷 2021-02-07 07:44

How would you inherit the template from a parent component in angular 4? Most materials exemplify overriding the parent component like this:

import { Component }         


        
相关标签:
2条回答
  • 2021-02-07 07:58

    if you want to add something to parent template you can just plus it

    @Component({
      selector: 'child',
      template: require('/path/to/child-template.html') + require('/path/to/parent-template.html')
    })
    

    (it is using webpack)

    0 讨论(0)
  • 2021-02-07 08:06

    Since you have a child component, you could place it in the parent's directory, and give it an URL that references the parent.

    @Component({
      selector: 'app-child',
      templateUrl: '../parent.component.html',
      styleUrls: ['../parent.component.scss']
    })
    
    0 讨论(0)
提交回复
热议问题