Questions tagged [angular-dynamic-components]

Questions about Angular Dynamic Components, an Angular technique for creating components during runtime. Use this tag for questions which are not specific to an individual version of Angular.

203 questions
2
votes
1 answer

Angular 13 how to configure manually lazy loaded module

I've tried everything to find a solution online and did research for days now but I'm unable to understand Angulars current concept of lazy loading module / components WITHOUT the router. My overall scenario: In my case my Angular App is only loaded…
2
votes
1 answer

Angular 13: Dynamically insert a component into a specific DOM node

I need to achieve something like in this question Angular 2 Dynamically insert a component into a specific DOM node without using ViewContainerRef I got a task to use the plain google maps api within an angular/ionic project. I want to add a button…
HdcDst
  • 41
  • 1
  • 4
2
votes
0 answers

Programmatically adding components at dynamic positions in Angular

My starting point is some kind of HTML snippet, which is loaded at runtime from my backend, with placeholder tags:
Col1
2
votes
1 answer

Angular – Dynamically load multiple instances of the same component by submitting a form to add a new instance of a component to the display

Question update link. Problem I’m trying to dynamically load multiple instances of the same component, with a new component being added/loaded to the screen when a user submits a form. The idea behind this is that a user can provide details on the…
2
votes
0 answers

How to unload or reload a SCSS for an Angular 11 component?

As far as I understood, Angular doesn't remove any on component destruction. But is there a way to reload a SCSS on dynamic component creation? What I want to achieve? I have a container that shall show different components of the same…
Lars
  • 920
  • 1
  • 14
  • 34
2
votes
1 answer

Way to inject angular FormBuilder service to dynamic component

I'm trying to inject the FormBuilder service to a dynamic component this way: Template: ...
... Component: @ViewChild('vc', { read: ViewContainerRef }) _container: ViewContainerRef; ... constructor(private fb: FormBuilder, …
2
votes
2 answers

How to use Pipes in Angular dynamic loaded components?

I need to load several components in a dynamic way. That is why I have created a parent component to do the job (depending on the value of this.rink), like: ngAfterViewInit() { switch (this.rink) { case 'ITCO': …
Lars
  • 920
  • 1
  • 14
  • 34
2
votes
2 answers

Pass @Input as Parameters fires Type 'string' has no properties in common with type

I am creating a dynamic tab based components and passing the necessary component properties to build the component through an object. How to pass @Input as a parameter and then use the input with ComponentFactoryResolver and create inputs. Here is…
Hary
  • 5,690
  • 7
  • 42
  • 79
2
votes
0 answers

Angular Unit Testing with Dynamic Component Failed with error TypeError: Cannot read property 'ɵcmp' of undefined

list of Angular dependency "@angular/common": "~9.1.1", "@angular/compiler": "~9.1.1", "@angular/core": "~9.1.1", "@angular/forms": "~9.1.1", "@angular/platform-browser": "~9.1.1", "@angular/platform-browser-dynamic":…
2
votes
4 answers

angular append component to respective tabs

I am trying to append component (dynamic created) to respective tabs using angular material and @viewChild but it is going to first tab only when I click button in the 2nd tab. Here is Stackblitz - angular-append-component-to-respective-tabs It's…
2
votes
2 answers

Using dynamic component within Angular structural directive produces extra HTML tag. How to remove or replace it?

I have quite complex infrastructure in my project which contains of host component structural directive used in host component's template (MyDir) another component used in structural directive (MyComp) Simplified version looks like the…
2
votes
1 answer

Load dynamic component multiple times with different data

I need to load a dynamic component multiple times and pass data dynamically based on some value so that it will load with runTime data. I have tried below example https://dzone.com/articles/how-to-dynamically-create-a-component-in-angular as per…
2
votes
1 answer

How to inject parent component service into dynamic component in Angular?

I am using Angular 8 and I have dynamically created component. I have parent component with the service into providers array. How I can inject the same instance of parent MyService into a dynamic component? Without dynamic component I can achieve it…
2
votes
0 answers

Dynamically ADDING and REMOVING Components as a form field in Angular

I have different buttons on template like input, checkbox, radio, button etc and on the click of each button their corresponding form field should get displayed. eg - on click of input button, input button component should be created dynamically…
2
votes
1 answer

Angular Dynamic Components AOT Issue

Due to some business logic, I have to read the meta data of dynamic components(EntryComponents). To read the meta data, following is my approach. Read all components of a module using ComponentFactoryResolver Filter out classes using Component name…
1 2
3
13 14