I have a service that returns an object map which is then used in Angular's ngFor
which only takes arrays. So, I am using the map operator with lodash's _toArray to convert the data to an array.
Although this works, I then have to import lodash everywhere I need to do this and it seems brittle. I was going to look into creating a custom operator, but perhaps there is an operator that already does this? I can't seem to find the right one(s)
Data:
{ 0 : {data : 'lorem'}, 1 : {data : 'lorem'}, 2 : {data : 'lorem'} }
Current:
this.http
.get('/api')
.map(data => _.toArray(data));
Possible?
this.http
.get('/api')
.mapToArray();