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.

Pipe for converting string to template reference

See original GitHub issue

πŸš€ feature request

Relevant Package

This feature request is for @angular/common

Description

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

github_iconTop GitHub Comments

5reactions
dawidgaruscommented, May 8, 2019

You can create a directive that registers a template in a service and pipe to retrieve it: https://stackblitz.com/edit/angular-hkwoby

2reactions
trotylcommented, May 7, 2019

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.

Read more comments on GitHub >

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

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