Another important task in real projects is combining several views on the same page. In other words, you separated Models and their corresponding separated Views (in different files), but you want to display all Views at the same time. So, let's consider the following example.
The Model will be as follows:
public class BookModel { public string Title { get; set; } public string Author { get; set; } } public class LibraryModel { public string LibraryName { get; set; } public List<BookModel> Books { get; set; } } public class ReaderModel { public string FirstName { get; set; } public string LastName { get; set; } public BookModel FavoriteBook { get; set; } } public class MultipleViewModel { public LibraryModel LibraryModel { get; set; } public ReaderModel ReaderModel { get; set; } }
The Controller will be as follows:
public class MultipleViewModelController : KnockoutController { public ActionResult Index() { var model = new MultipleViewModel...