please go through the link: http://jsfiddle.net/nn0mfe48/1/
Here i am able to use knockout WITH binding when i use object literal, but when i change it to function same code doesn't work.
Works:
var profileModel = {
first: ko.observable("Bob"),
last: ko.observable("Smith"),
};
Doesn't work:
var profileModel = function() {
this.firstname= ko.observable("Bob");
last: ko.observable("Smith");
};
what do i need to change in code to make it work. My need of hour is to pass knockout viewmodel object to viewmodel and bind the value dynamically instead of hard coding the values.
i had gone through the link : Difference between knockout View Models declared as object literals vs functions
but couldn't understand how can make use in my case. hope i explained clearly and understandable. any help in this regard is appreciated.thanks in advance.