typescript - loading observableArray -


i'm using knockout in typescript, want load data returned db observablearray.

i tried below code, got exception:

object doesn't support property or method 'map'

in constructor:

this.boxes = ko.observablearray<box>(data[0].box || []).map(e => new box(                 e.index,                 e.title,                 e.value,                 e.category             ));   this.boxes = ko.observablearray<box>([]); 

map method on normal javascript array, not observablearray, need perform mapping on array response data before passing ko.observablearray<box>():

this.boxes = ko.observablearray<box>((data[0].box || []).map(e => new box(             e.index,             e.title,             e.value,             e.category         ))); 

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -