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
4
votes
4 answers

Angular dynamic component property binding

I have created a dynamic component in Angular 6 with componentFactoryResolver, and I need to update one of its properties every 3 seconds. const componentFactory = this.cfr.resolveComponentFactory(componentType); const component: ComponentRef =…
Emanuel T
  • 53
  • 1
  • 5
4
votes
1 answer

How to pass i18n key from parent to child component before translation starts?

I'am using an input-field component which I can embed in different parent components using forms. In the input child component, I have an i18n translation key as variable using interpolation, which I would like to generate dynamically from parent…
4
votes
1 answer

How to load one dynamic component for each step on stepper

The thing with my problem is that I have to load one component of an array dynamically on each step of my stepper on the template. I followed the Angular guide for loading dynamic components into the template, but for now I am only capable to render…
3
votes
0 answers

Angular 13 how to create dynamic component with inputs and outputs outside app-root?

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…
3
votes
1 answer

Dynamically loaded content in Angular Material Tabs

I'm trying to build a dynamic tab-system from Angular Material: Tabs and I'm running into an issue with the loading of content on subsequent tabs, where the concept only works on the first tab being loaded. Below is the tab-group. The tabs are…
3
votes
1 answer

Angular 8 - Dynamic component creation without ng-component tag

I am building a directive for my app that creates dynamically component and inject it right after the element it decorates. The directive is working perfectly except one issue: When the component is added to the view by the directive, it contains…
Koby Mizrahy
  • 1,361
  • 2
  • 12
  • 23
3
votes
1 answer

ViewContainerRef vs ngFor

What is better? Use ngFor or ViewContainerRef to dynamically create components? What is the difference? For example, if I have a button to create a new element that every time I press it generates a new component. 1) The first option would be the…
Mr. Mars
  • 762
  • 1
  • 9
  • 39
3
votes
1 answer

Angular Dynamic Components: How to Set and Get Data

I need to create components dynamically based on a predetermined type, and be able to set and get data from them. Up until now I'm able to create and show the componentes, but I don't know how to set or get data from them. This is how i'm adding and…
Ricky
  • 2,912
  • 8
  • 47
  • 74
3
votes
1 answer

How to do dependency injection for Dynamic Angular Components

I am trying to build a dynamic component inside any container. I needed some predefined services and injections available in the angular world inside the dynamically created component. Primary reason for this there is an external service that holds…
3
votes
1 answer

How to use DynamicModule.withComponents of ng-dynamic-component without creating dependency for those components?

I have 3 modules with a component in each: tasks >tasks -tasks.component.ts|html|css -tasks.module.ts people >people -people.component.ts|html|css -people.module.ts dynamic-container >dynamic-container …
char m
  • 7,840
  • 14
  • 68
  • 117
3
votes
1 answer

Creating nested dynamic components in angular

I Want to know how to create nested dynamic components and maintains its parent child relationship. For example, I have data like this, - A --A.1 --A.2 -B --B.1 -C I wanted to create the component like this,
3
votes
0 answers

Setting dynamic routes using router.config.unshift() only works if its used from `AppComponent app.component.ts`

I am using Angular 4 and I am trying to set the routes dynamically using some external data. Based on some of solutions provided over the internet I am trying to load the routes dynamically by invoking : …
2
votes
0 answers

Updating Angular, Error with my dynamically created components. "error NG1010: template must be a string Value is a reference to '"

I've taken over an old Angular project at my work and I'm tasked with upgrading it from version 6 to 14. I've gone one version at a time as recommended by the Angular Update Guide. But now at version 13 I'm stuck at an issue with some dynamically…
2
votes
0 answers

Add ng-container dynamically in Angular app

I am going to add a dynamic component to the Angular template. Usually, it is done by creating a dynamic component via the existing ViewContainerRef in the template. But what about the situation where there is no ability to define manually? Is…
Sergey E.
  • 21
  • 1
2
votes
0 answers

Change detection not working when creating a dynamic component with nested input data

I have an issue with change detection not firing the child ngOnChanges method for child components created dynamically using angular 13. Here i have two dynamic components mainly Button Block Text Block Initially when the application loads the…
1
2
3
13 14