I use a lot of inheritance between my Angular components.
Sometimes, I would like to be able to inherit from a specific component, and not provide some html for the child (because it is always going to be the same as the parent) which leads to duplicate code everywhere.
What is the best way to achieve this ?
@Component({
selector: 'app-parent',
templateUrl: './parent.component.html',
styleUrls: ['./parent.component.scss']
})
export class Parent {
}
@Component({
selector: 'app-child',
template: '', <-- you have to provide a template
})
export class Child extends Parent {
}
templateUrl: './parent.component.html',? any reason you do not want to do this?templateUrlpath can be done.../../parent.component.htmlto go back/up two directories. It gets messy fairly fast though.