When creating a select control, with options that may be pulled from a database, it seems customary to put an ngFor on the template side to render the options.
What I want to do is instead have a loop on the component side that builds a string with the options:
for (var i = 0; i < 20; i++) {
this.selectOptions += "<option value=" + i + ">" + i + "</option> ";
}
Then in the template side of something like this:
<select>
{{selectOptions}}
</select>
The reason I want to do this is I have some nested loops in a complex UI, and several selects that have the same options. Once rendered the options do not change.
I want to get rid of all the ngFors that are running in order to try to speed up my UI. There are other things I need to do as well, but this is something that I think could help. Then the loops for the options only have to run 1 time instead of over and over.