Questions tagged [viewchildren]

31 questions
6
votes
1 answer

How to get the Component instance of from ViewContainerRef.get() for components created dynamically

Summary of what I'm trying to accomplish dynamically add components to a ViewContainerRef (done) initialized these Dynamic components with properties (done) get access to the dynamically created Component instances so that I may make decisions…
Edward
  • 1,076
  • 1
  • 12
  • 24
3
votes
0 answers

Angular ViewChildren returning undefined

I've gone through quite a few other questions on SO related to this Angular feature and none of the solutions seem to help my scenario. I'm utilizing the Angular Material tree component, and am attempting to generate a component within a fully…
Josh Ray
  • 291
  • 2
  • 7
2
votes
2 answers

How to update the styles of @ViewChildren (Or @ContentChildren) in Angular(v14)

I'm trying to create a carousel component that has n amount of child components based on whatever size list it will get. I want the parent (carousel) to control the styling for children as it manipulates the size of the list and track the indexes to…
2
votes
0 answers

Angular Get list of dynamic components

I need to loop throughout over nested child components inside on div. I try that with ViewChildren but I got only a list of created components and when I create a dynamic component, Unfortunately, the list is not updated. I tried to manually run the…
FarbodKain
  • 229
  • 3
  • 15
2
votes
1 answer

How to Access child component property in spec file as QueryList in Angular using @viewChildren

I have the below code in the parent.component.ts file, where I'm accessing the child grid as QueryList using @ViewChildren. @ViewChildren(ChildComponent) childComponent: QueryList; I have this below function in the component where I accessed…
knbibin
  • 1,099
  • 7
  • 18
  • 36
2
votes
1 answer

Angular DOM reorder elements in QueryList

I have a QueryList of objects. I need to reorder the DOM element based on user interaction: @ViewChildren('mytemplate') temp: QueryList; In ngAfterViewInit : let arr = this.temp.toArray(); // sort the arr here (it gets…
1
vote
1 answer

Angular 12 ViewChildren in ngFor directive causes ExpressionChangedAfterItHasBeenCheckedError

I've a parent component from which is possible to open various tab containing the child component This is a part of parent component: ....
Dragon981
  • 23
  • 3
1
vote
1 answer

Angular - Access list of child components on page load

I am using Angular 10 for a side-project of mine. I have a page that, on page load, retrieves a list of entries (in this case specifically spells) from the server and renders 1 child-component ( component) per entry on that page. The user…
Philipp Doerner
  • 1,090
  • 7
  • 24
1
vote
0 answers

get 'Undefined' when using @ViewChildren Angular

I am using the decorator @ViewChildren to send a data form from the child component to the parent component. This is my parent component.ts: @ViewChildren('child') generalDataComponent : GeneraldataInfoComponent; saveAndGoForUpload()…
hiba nebli
  • 107
  • 2
  • 18
1
vote
1 answer

Using QueryList gives the first HTML element

I'm using Angular 10, and trying to use QueryList, with the code below (just like many examples on the web) HTML
some content
TS @ViewChild('someID') someIds: QueryList; When running…
Erez Shlomo
  • 2,124
  • 2
  • 14
  • 27
1
vote
1 answer

Angular ViewChildren can't get changed reactive form value

I have one parent component and multiple children components. I'd to get children's valid reactive form value when I click a button in parent component. However, I can only get originally patched form value with ViewChildren. In child component, I…
kehua
  • 11
  • 1
1
vote
0 answers

@ViewChildren getting undefined values

I have a library of web components (custom elements) that I expect to use in other angular applications. The issue is @ViewChildren() getting undefined values, unable to access the children inside my component. I use @ViewChildren because I am using…
1
vote
0 answers

Angular ViewChildren with nested children

The documentation for ContentChildren cleary states, that QueryList will not fetch anything inside child components. It doesn't state the same for ViewChildren though, so I am asking myself, if there is something I am doing wrong…
pop
  • 3,464
  • 3
  • 26
  • 43
1
vote
2 answers

Angular ViewChildren from nested ngFor but group them by parent ngFor

When i have nested ngFor how to group children by parent ngFor? So i had something like this: html:
kkamil4sz
  • 431
  • 1
  • 5
  • 19
0
votes
0 answers

ViewChildren change text content for an element added dynamicly

I want to change the text content inside a span property by accessing it by an Id. When the spans elements exist already, I am able to change the content after hitting a button, but when the spans elements are added dynamicly, the text content does…
Kivo
  • 385
  • 8
  • 24
1
2 3