Knockout.js mapping a JSON into an observable-array

后端 未结 1 904
夕颜
夕颜 2021-01-04 00:42

I want to build a client for my REST-Service using Knockout.js. I have a lot of Repositorys i want to access through different urls - so i came up with this solution using

相关标签:
1条回答
  • 2021-01-04 01:20

    I believe that the two argument version of fromJS is only used for objects that were previously mapped, i.e they had an implicit empty mapping options object. Since your mapping is the first time it has been run, it needs to provider that empty options object like so.

    ko.mapping.fromJS(data, {}, self.Items);
    

    http://jsfiddle.net/madcapnmckay/j7Qxh/1/

    Hope this helps.

    0 讨论(0)
提交回复
热议问题