What is the best way of cloning/copying an observablearray in knockoutJS?

后端 未结 4 764
终归单人心
终归单人心 2020-12-13 12:41

Question says it all really. I want to copy an observable array to another in KnockoutJS.

4条回答
  •  孤街浪徒
    2020-12-13 12:52

    Assuming you have something like:

    modelA { someValues: observableArray(); }
    modelB { iWantYourValues: observableArray(); }
    

    You should be able to:

    modelB.iWantYourValues(modelA.someValues())
    

提交回复
热议问题