Need to pass initial viewmodel data from ASP.NET MVC to knockout.js

后端 未结 3 1131
再見小時候
再見小時候 2021-02-04 18:09

I was looking at the Contacts editor sample on the knockout.js website:

http://knockoutjs.com/examples/contactsEditor.html

The sample works perfectly, but I need

3条回答
  •  耶瑟儿~
    2021-02-04 18:51

    You could also use your model instead of the ViewBag:

    Controller:

            public ActionResult Index()
            {
                var data= GetYourDataFromSomewhere();
    
                return View(data);
             }
    

    View:

    @model IEnumerable
    

    ....

    
    
                                     
                  
提交回复
热议问题