I am using knockout.js options binding on select-list. I created an example fiddle:
http://jsbin.com/uzecaf/12/edit
But the problem is instead of showing value text on ui, [object object] is displayed on ui. What i am doing wrong?
EDIT
Js Code
function AuthorVM(){
this.Name = ko.observable("bla-bla");
this.books = ko.observableArray(
[
new BookVM('book-1', '1'),
new BookVM('book-2', '2'),
new BookVM('book-3', '3'),
new BookVM('book-4', '4')
]
);
}
function BookVM(name, id){
this.Name = name;
this.Id = id;
}
ko.applyBindings(new AuthorVM());
MarkUp
<label data-bind="text: Name"></label>
<select data-bind="options: books, optionsText: Name">
</select>
Your
selectbinding is wrong, the optionsText parameter is astringso you need pass there a property name as a string.Your binding should look like:
See Demo.