Angular 4-component inheritance and "view extension"

When you do component inheritance in angular like

export class ChildComponent extends ParentComponent{}

You can get all the logic from the ParentComponent, but you need to implement all the html again.

Say my ParentComponent html looks like this:

<div class="card">
    <div class="header"></div>
    <div class="content"></div>
    <div class="footer"></div>
</div>

Is there a way that I can “implement” a parent component in which the view type of the child component only implements the “content” div?

eg

@Component({
   template:`<div class="content-of-child">...</div>`
})
 export class ChildComponent extends ParentComponent{}

so the result will be

<div class="card">
        <div class="header"></div>
        <div class="content-of-child"></div>
        <div class="footer"></div>
    </div>
+4
source share
1 answer

, , , , - 3 "". , .

0

Source: https://habr.com/ru/post/1686064/


All Articles