Select value (not text) of dropdown in Ionic 4

countrycode is not the same as country, so I don’t think you’re accessing the right control. This is partially why I never use formControlName. I put each FormControl into a separate controller property and bind [formControl] instead. That way my IDE and build tools catch typos that can’t get caught when you write controls['countrycode'], and (although this is admittedly very minor on modern hardware) it saves a needless hash table lookup.

I didn’t understand why this existed in the first place, I don’t understand why it’s there now. There must be something else in your actual code that you’re not posting - that shouldn’t even compile, let alone do anything useful. I would not consider this a sustainable state of affairs, but rather a step backwards into spaghetti.

Create a different topic for this issue: it’s unrelated. Incidentally, see this thread for a discussion of why you don’t need asObservable here (or, arguably, anywhere).

1 Like