Could you do me a favor?
environment is angular9 and primeng.
I have two pages.
- show detail.
- edit/create.
2.has p-dropdown component. this is working fine.
<p-dropdown name="type" [options]="types" [(ngModel)]="info.type">
1.is problem. i can display value but not label. I tried as follow. this is not working.
{{types[info.type].label}}
List is defined like this. x.component.ts
readonly types: SelectItem[] = [ { label: '---', value: null }, //index=0 { label: 'a', value: '0' }, //index=1 { label: 'b', value: '1' }, //index=2 { label: 'c', value: '2' }, //index=3 ];
if info.type = 1, right answer is 'b' but it returned 'a'.
types[info.type].label // <-this is recognized as index, not value.
How to search list from value? My image is like this.
types[value -> info.type].label
or
types['' + info.type].label
ofcourse these are not work. I have 350 dropdowns in my page, so if possible, do not want to write convert code in component.ts.
info
is defined? – Michael D