In my angular 15 app I have many components that use the same template, by referencing to the same template file in TemplateUrl.
for example:
@Component({
selector: 'app-my-comp',
templateUrl:'../../myTemplate.html',// this is a common template,
})
export class MyComponent {
}
For some reason I need to take the myTemplate.html of the app, and set it in an external library in my project.
How can I export a HTML template from a library (in a library's public API I can export only ts files)?
How can I use it in the TemplateUrl of
MyComponentcomponent?
maybe I am wrong but I don't think this is possible. Also using the same Template in multiple components is something to use with caution.
Maybe you should explain your use-case and then we can look for different solutions/architectures.
For example if you need the same template but different functionality, you should move the UI in a so-called "dumb component" and re-use it in multiple smart components.