I wish to convert an Ionic's storage object to an array to be readable in a ion view.
I get this error : NgFor only supports binding to Iterables such as Arrays.
How to convert an object to an array ?
Do i have to forEach storage the push the data to an array ?
This is the object :
Regards
Frank
Asked
Active
Viewed 482 times
-1

zgue
- 3,793
- 9
- 34
- 39

de albuquerque frank
- 187
- 3
- 14
-
Possible duplicate of [Typescript Convert Object to Array - because \*ngFor does not supports iteration of object](https://stackoverflow.com/questions/41458400/typescript-convert-object-to-array-because-ngfor-does-not-supports-iteration) – Red fx Oct 24 '17 at 10:04
-
Can you show your object? – Faly Oct 24 '17 at 10:17
2 Answers
0
You can use ES6's Object.values to get an array of values:
var obj = {
"1": { prop: "xxx" },
"2": { prop: "yyy" },
"3": { prop: "zzz" }
}
var arr = Object.values(obj);
console.log(arr);

Faly
- 13,291
- 2
- 19
- 37
0
I try an approch to get an array of the storage ionic object like this:
this.storage.forEach((value: string, key: string, index: number) => {
//console.log(key);
console.log('value',value);
});
It returns an array of the object but with additional values ! Strange ..... Solution from here

de albuquerque frank
- 187
- 3
- 14