N
N
no_like2018-06-10 15:51:36
Angular
no_like, 2018-06-10 15:51:36

How to make Angular5 component inherit and extend parent heatplate?

Angular5. I already have a written component with implemented functionality. I want to make a child component based on it, inherit the logic, but at the same time replace part of the parent template:

@Component({
  selector: 'app-parent',
  template: ' //reusable header element with logic

              *here we should have ability to change part of tamplate*
               <ng-container *ngTemplateOutlet="customTemplate"> </ng-container>

       //reusable footer element with logic
'
})
export class ParentComponent{
//logic impl

Child component:
@Component({
  selector: 'app-child',
  template: '
             //here i wanna extend parent template
             /*something like*/ <ng-template #customTemplate>
             //some template impl
</ng-template>'
})
export class ChildComponent extends ParentComponent{}

(it is possible to make a special abstract component and put everything in common into it).

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question