Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70434

Error: Uncaught (in promise): TypeError: this.l_drink is not iterable

$
0
0

Hi,
Following this topic: https://forum.ionicframework.com/t/how-to-dynamically-feed-the-this-validations-form/187947/2 ,

I’m blocked now with this error message: Error: Uncaught (in promise): TypeError: this.l_drink is not iterable

In the .ts:

export class NewOrderPage //implements OnInit
{

drinks: Observable<Drink>;

constructor(

personService: PersonService
) {

this.drinks = personService.getAllDrinks(); 

When I try with the following block, Visual Studio Code complains on this.drinks about
Type ‘Observable<PersonNames[]>’ must have a ‘Symbol.iterator’ method that returns an iterator.

for (let c of this.drinks) {
ctrls[drk_${c.id}] = new FormControl(false);
ctrls[drk_amt_${c.id}] = new FormControl(’’);
}

Then I tried with

this.drinks.subscribe((value) => { 
  this.l_drink = [...value];
});

let ctrls = {};

for (let c of this.l_drink) {
ctrls[drk_${c.id}] = new FormControl(false);
ctrls[drk_amt_${c.id}] = new FormControl(’’);
}
this.validations_form = this.formBuilder.group(ctrls);

but then it crashes in the console with Error: Uncaught (in promise): TypeError: this.l_drink is not iterable

Can you please advise me how to fix that?..

For info, in the type.ts

export default interface Drink {
id: string;
name: string;
};

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 70434

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>