Is there any alternate way in angular to achieve what ng-include does in angularjs?
The closest to ng-include is ngTemplateOutlet directive. You need to pass a TemplateRef to it and optional context. Something like that:
@Component({
selector: 'child',
template: `
here is child template that includes myTemplate
`
})
export class ChildComponent {
@Input() myTemplate: TemplateRef;
}
@Component({
selector: 'app-root',
template: `
Parent
hi julia template!
`
})
export class AppComponent {
@ViewChild('myTemplate', {read: TemplateRef}) myTemplate: TemplateRef;
}