question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature Request: Add switch to ng build to omit inclusion of external templateUrl from components.

See original GitHub issue

Bug 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:closed
  • Created 6 years ago
  • Reactions:4
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
davemvpcommented, Apr 16, 2018

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.

1reaction
Broccocommented, Aug 18, 2017

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Run ng build and omit templates - Stack Overflow
Is there a switch or configuration option to run ng build and have it not inline the templateUrl from the angular components?
Read more >
Your options for building Angular Elements
In this article, I provide several strategies you can use to provide external web components already today. Some of them will definitely ...
Read more >
Component - Angular
templateUrl ? The relative path or absolute URL of a template file for an Angular component. If provided, do not supply an inline...
Read more >
An Angular 5 tutorial: step-by-step guide to your first Angular 5 ...
Some developers will tell you that it's better to use React and build your own components without much additional code.
Read more >
Building an Angular Front End for an ASP.NET Web API
This causes the title property from the component to render. Let's make a small addition by adding a time value so you can...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found