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: templateUrl multiple named template script selection

See original GitHub issue

I 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:closed
  • Created 7 years ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Kriskitcommented, Nov 22, 2016

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.

1reaction
d3lmcommented, Sep 7, 2016

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?

Read more comments on GitHub >

github_iconTop 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 >

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