vendredi 4 mai 2018

Q: ng-select async pipe with an observable to object instead of an array

I'm trying to load my select with data from an backend API, https://ng-select.github.io/ng-select#/data-sources shows with an observalble to an array, but my observable is to an object from a json like:

{
    //some other non used data
    .
    . 
    .
    "rows":[] //data that i want in my options of the select
}

since i had no ideia how to do in this case, i tried just use normaly the asyncPipe :

<ng-select [items]="events$ | async" (data)="selEvent($event)">
</ng-select>

but got an error in value.filter:

ERROR TypeError: value.filter is not a function
at SelectComponent.set [as items] (select.js:54)
at updateProp (core.js:12601)
at checkAndUpdateDirectiveInline (core.js:12312)
at checkAndUpdateNodeInline (core.js:13878)
at checkAndUpdateNode (core.js:13821)
at debugCheckAndUpdateNode (core.js:14714)
at debugCheckDirectivesFn (core.js:14655)
at Object.eval [as updateDirectives] (NewTriggerComponent.html:17)
at Object.debugUpdateDirectives [as updateDirectives] (core.js:14640)
at checkAndUpdateView (core.js:13787)

someone knows how should i do it?




Aucun commentaire:

Enregistrer un commentaire