Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

How to add ng-template in angular component from base component or directive or service

I am working on angular project. Most of forms are same and my lot of html gets repeated. e.g. save cancel button UI. I have base component which handles init, get, save logic. Child component has form UI and logic only specific to child.

i can create one service/directive/component which has list of all common html and i can plug it in any component i need.

link to stackblitz. https://stackblitz.com/edit/angular-jvqj63

I this sample code I have #okCancel template in child1, child2 and base components. How can I have only one copy of this and use everywhere?

Basically i want to define repetitive html in place be it parent component / directive / service and use them wherever you need.

Comments