I have a question about how I create my object:
var myViewModel = new MyViewModel("other");
Why am I unable to call myViewModel.setHasOne(value)
from outside the viewmodel?
Whenever I try, I encounter this error message:
Uncaught TypeError: Cannot call method 'setHasOne' of undefined
Although I can set the properties directly, I am keen on understanding how to achieve it using a method.
Below is the function I am referring to:
function MyViewModel(other) {
var self = this;
self.other = other;
self.hasOne = false;
this.setHasOne= function (value) {
self.hasOne = value;
};
return this;
}