all AI news
Inserting programmatically created components with templates and content projection in Angular
May 26, 2023, 5:53 p.m. | Ayyash
DEV Community dev.to
Previously we tried hosting the newly created component in an HTML element, whether existing in body
, or created and appended to body
. Today we try two other ways:
- Hosting in
ng-template
- Content projecting in
ng-content
Follow along with StackBlitz project.
Hosting in a ng-template
What we need is a reference to that template, to use it as a host element. Is it doable? Let's dig in.
First, we add a template, and declare it. (I created a new …
angular components html project projection template tutorial typescript webdev
More from dev.to / DEV Community
Jobs in AI, ML, Big Data
Data Engineer
@ Lemon.io | Remote: Europe, LATAM, Canada, UK, Asia, Oceania
Artificial Intelligence – Bioinformatic Expert
@ University of Texas Medical Branch | Galveston, TX
Lead Developer (AI)
@ Cere Network | San Francisco, US
Research Engineer
@ Allora Labs | Remote
Ecosystem Manager
@ Allora Labs | Remote
Founding AI Engineer, Agents
@ Occam AI | New York