Creating a ViewModel from the server

If you’ve been doing much work with KnockoutJS you’ll probably see examples where the code looks like this:
var todoViewModel = function() { this.items = new ko.observableArray([‘Item 1’, ‘Item 2’, ‘Item 3’]); this.selectedItem = new ko.obs…

If you’ve been doing much work with KnockoutJS you’ll probably see examples where the code looks like this: var todoViewModel = function() { this.items = new ko.observableArray(['Item 1', 'Item 2', 'Item 3']); this.selectedItem = new ko.observable('Item 1'); }; What I’m trying to point out here is that the viewModel is being defined in JavaScript and that the items within it are coded into your JavaScript. While you can argue that this is demo code and it should only be treated as such something I’ve noticed is there isn’t any other examples.
Print Share Comment Cite Upload Translate
CITATION GOES HERE CITATION GOES HERE
Select a language: