Feature Request: Add switch to ng build to omit inclusion of external templateUrl from components.
See original GitHub issueBug Report or Feature Request (mark with an x
)
- [ ] bug report -> please search issues before submitting
- [X] feature request
Desired functionality.
Summary
Add switch to ng build
to omit inclusion of external templateUrl
from components.
Use Case
The example is specific to Microsoft’s MVC platform but might also apply to other platforms as well. Multi-lingual Microsoft MVC applications usually make use of resource files (.resx) which contain localized texts. These texts are injected at runtime into the mvc templates (.cshtml files) and the templates can also contain c# code (executed server side before the template is served at runtime). When adding Angular to an existing Microsoft application I would prefer to continue to use the existing resource files instead of trying to convert to a whole new localization scheme based on the Angular i18n.
If a switch were added the script bundle(s) could be created using ng build
that would bundle the angular files and still allow the Microsoft MVC framework to host the html (cshtml) templates at runtime.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:4
- Comments:6 (2 by maintainers)
I have a similar requirement in that I want to serve my templates from a CMS. I would also like to support local templates in the same app. There are simple shared components that don’t require the CMS template overhead and therefore could be rendered at build time.
I ran across this article on Stack Overflow, https://stackoverflow.com/questions/41473511/how-to-render-asp-net-mvc-view-into-angular-2?rq=1, but the solution appears to only allow content and basic binding. It does not appear to allow you to render a template for a component at runtime which contains other components.
A more preferred solution to a switch that disables templateurl inclusion in the build might be the way Aurelia handles this use case. Its bundler seems to ignore template paths it cannot find locally. This allows you to serve templates from an external source such as a MVC site or a CMS.
This is something I would suggest against. By heading down this approach you lose the ability to do AOT compilation (which happens at build time) because the
cshtml
files are evaluated at run time.