Knockout.js how to access the inner object property on data-bind

后端 未结 5 1874
春和景丽
春和景丽 2021-01-03 19:48

I\'ve a super simple knockout code below:

var data ={
    \"Id\" : 1001,
    \"SalePrice\" : 12345,
    \"ListPrice\" : 333,
    \"ShortDesc\" : \"Tayler 123         


        
5条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-03 20:27

    Call to ko.observable needs to be moved from MVVM to HTML element:

        var data ={
        "Id" : 1001,
        "SalePrice" : 12345,
        "ListPrice" : 333,
        "ShortDesc" : "Tayler 12345E",
        "Description" : " Long Description"
    };
    
    
    var viewModel={
        dataTest: data
    };
    
    
    ko.applyBindings(viewModel);
    
    
    

提交回复
热议问题