Pipe for converting string to template reference
See original GitHub issueπ feature request
Relevant Package
This feature request is for @angular/commonDescription
If we need to use[ngTemplateOutlet]="templateName"
The βtemplateNameβ should be defined in component and should be of type TemplateRef.
Problem described with an example here - https://stackoverflow.com/questions/56001849/how-to-convert-string-to-an-template-reference-instance
Describe the solution youβd like
I should be able to convert the string type from a property to templateRef type using a pipe like below[ngTemplateOutlet]="templateName | templateRef"
In this case templateName can be string.
Describe alternatives youβve considered
Here is the current alternative to the problem described above. https://stackblitz.com/edit/ng-template-outlet-mhpnas?file=app/app.component.ts
Issue Analytics
- State:
- Created 4 years ago
- Reactions:7
- Comments:5 (3 by maintainers)
Top Results From Across the Web
How to convert string to an template reference instance?
I have defined [ngTemplateOutlet]="item.type" and expecting item.type to have different names corresponding to template reference variables. βΒ ...
Read more >Transforming Data Using Pipes - Angular
Use pipes to transform strings, currency amounts, dates, and other data for display. Pipes are simple functions to use in template expressions to...
Read more >Transforming Data Using Pipes - Angular
Use pipes to transform strings, currency amounts, dates, and other data for display. Pipes are simple functions you can use in template expressions...
Read more >Built-in Pipes - The Angular Book
The TitleCasePipe converts input text to the title case. That means that first character gets converted to upper case while the rest of...
Read more >Step by Step Custom Pipes in Angular - Ultimate Courses
Creating a Custom Pipe ... All we need to do is supply a name property that corresponds to our template code name as...
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
You can create a directive that registers a template in a service and pipe to retrieve it: https://stackblitz.com/edit/angular-hkwoby
Pipes are just normal user code, no pipe can bring extra capability to framework runtime. Youβll need to request an imperative view children query API first.