Let below is a component which I will be extending in various other components ti reuse some code..
import { Component } from '@angular/core';
@Component ({
selector: 'my-app',
template: ` <div>
<h1>{{appTitle}}</h1>
<div>To Tutorials Point</div>
</div> `,
})
export class AppComponent {
appTitle: string = 'Welcome';
ngOnInit(){
this.registerSomeSubscriptions();
}
registerSomeSubscriptions(){
this.subscribeSomething.subscribe((data)=>{
performSomeAction();
})
}
}
I can extend it like below
import { Component } from '@angular/core';
@Component ({
selector: 'my-app',
template: ` <div>
<h1>{{appTitle}}</h1>
<div>To Tutorials Point</div>
</div> `,
})
export class ChildComponent extends AppComponent {
}
While I know that public members of the component will be available in the child component.
My Question
- Do I still have to use separate html files for both the components or is thier some of code style or problem solving technique to reuse the same html template along with some child specific implementation by some technique I am not aware of.