Ion-Select-Option - array name in variable

Is there anyway to specify the name of an array via a variable that contains the array name in a ion-select-option * ngfor directive ie
Instead of * ngfor let hero of heros

  • ngfor let hero of variable

This is a really bad idea, because even if you kludge something together, it is virtually certain to break in production due to minification. Can you back up and describe what you are actually trying to do in business instead of technical terms?

I’m trying to create a UI where values available in a selection item ( drop down list box) are chosen at run time depending on some other condition ie the array to be used is decided at runtime.

I maybe wrong but I believe the underlying Angular directive NgForOf does allow this functionality.

Not sure i fully understand what you mean by minification issues during production. But i’m not worried about that at this stage.

I can get around it by simply defining separate Select controls and using *ngif but i was looking for a more elegant solution.

I think you should be worried about it, because it will be pretty frustrating if you commit to a particular design decision now and then later discover that it’s not going to work when it comes time to distribute the app.

The bottom line is that you should never write any code that depends on the name of any class, property, or function as a string. Part of the production build process makes the code bundle smaller by silently transforming named things to have smaller names.

The template shouldn’t ever hear about any of this. What I would do is to write good old *ngFor="let hero of heroes" in the template, and do all the magic populating heroes in the backing controller. I think you might be able to adapt this two-level select example to your situation, as it is effectively swapping out the choices available for one select based on choices made in another.