What is the proper way to access QueryList results
See original GitHub issueAccessing child components with the Query()
annotation like this:
constructor(@Query(Type) query:Type) {
}
Gives us a QueryList
object that comes with methods to add()
, remove()
, … etc.
The results of the query are located in query._results
. Since it has an underscore in it’s name, I thought it might be rather considered private. But I couldn’t find a method getResults()
or alike.
Is it okay-ish to access _results
here, or is there a better way to get hold of them?
Issue Analytics
- State:
- Created 8 years ago
- Reactions:2
- Comments:7 (4 by maintainers)
Top Results From Across the Web
angular 4 how to access ViewChildren _results - Stack Overflow
Call the toArray() method: this.hangchecks.toArray().forEach((item) => {.
Read more >QueryList - Angular
This function is executed for each element of the query result list while comparing current query list with the new one (provided as...
Read more >Angular - Understanding How To Use QueryList Properly.
In this post we will go through all the ways we can leverage the QueryList object ... Angular – Understanding how to use...
Read more >Understanding ViewChildren, ContentChildren, and QueryList ...
Let's see how we can handle this with Angular. @ViewChildren —. Returns the specified elements or directives from the view DOM as QueryList....
Read more >Understanding ViewChild, ViewChildren & Querylist in Angular
ViewChild & ViewChildren are used to Query & get the reference of the DOM element into component. ViewChild returns a element & ViewChildren ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
It seems shortsighted to not have this accessible by index (very frustrating to work with it).
No
_results
is private. The correct way is to iterate over it is using the ES6 construct.