Feature Request: templateUrl multiple named template script selection
See original GitHub issueI am submitting a feature request for an Component directive ‘templateUrl’ #name extension
given an templates.html with
<script name="aScriptTemplate" type="text/template">
<h1>Angular 2 App with script templates</h1>
</script>
<script name="anotherScriptTemplate" type="text/template">
<h1>Angular 2 App with multiple script templates</h1>
</script>
and
@Component({
selector: 'my-app',
templateUrl: 'templates.html#aScriptTemplate'
})
....
@Component({
selector: 'my-template,
templateUrl: 'templates.html#anotherScriptTemplate'
})
....
Issue Analytics
- State:
- Created 7 years ago
- Comments:11 (4 by maintainers)
Top Results From Across the Web
multiple templateUrls for @Component definition · Issue #28161
Here is another use-case for this feature request... (1) A model entity with many fields, (2) A CRUD form and component to view/edit...
Read more >Angular directive templateUrl relative to .js file - Stack Overflow
The currently executing script file will always be the last one in the scripts array, so you can easily find its path: //...
Read more >Link templates for deployment - Azure Resource Manager
Describes how to use linked templates in an Azure Resource Manager template (ARM template) to create a modular template solution.
Read more >AWS::CloudFormation::Stack
The AWS::CloudFormation::Stack resource nests a stack as a resource in a top-level template. You can add output values from a nested stack within...
Read more >Difference between Template and TemplateURL in AngularJS
The major two important properties are template & template URL. ... It refers to write the required HTML inside the typescript file.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Like @d3lm we have need for bundling our templates into a single URL to reduce the number of template requests. We cannot support AoT as our underlying ASP.NET MVC site is using a proprietary CMS which enables us to edit content in the templates, these can be multi-language and vary depending on client type (desktop/mobile) using a custom UrlResolver.
I don’t think some sort of crazy online process that compiles the templates every time someone updates the content in the CMS would be appropriate. However, being able to specify multiple component templates in a single file would be useful.
I actually like this feature request. My motivation behind this that I could fetch for example the template for a container component via HTTP. When using an ASP.NET backend, if you request a
.cshtml
file, that template gets rendered on the server side. I could then include script tags for other templates inside there, which will also be rendered on the server side. So I reduce the amount of HTTP calls tremendously. Only the template for the container is fetched and all sub-templates for inner dumb components is “inlined” via script tags. AoT does not work for server side rendering in combination with a C# backend, does it?