Is there a way to delay the subscribe
function until my logic is complete and the transform
method has updated the keys
object?
transform(value: any, args:string) : any {
let keys = [];
this.http.get('src/app/enum-data/enum.json').subscribe(data => {
this.List = data;
// Implement logic here (comparing data vs value)
for (var enumMember in value) {
if (!isNaN(parseInt(enumMember, 10))) {
keys.push({key: enumMember, value: value[enumMember]});
}
}
},
err => {
console.log(err);
});
return keys;
}
HTML:
<select>
<option *ngFor="let item of gendersEnum | keys: 'gender'" [value]="item.key">{{item.value}}</option>
</select>
This involves a custom pipe
module. I attempted to return keys
within the subscribe
, but encountered the same issue.