How to pass a dynamic template reference variable in a function using angular 6
You can use the ViewChildren
decorator which returns a QueryList
: you don't need to use an index anymore, Angular will handle all of that for you.
See this stackblitz to see it in action (open your console before clicking on the buttons)