I am having issues with the binding context using ES6 classes.
here is a jsfiddle to explain.
when i declare a click function on the class like
class viewModel {
constructor() {
this.data = ko.observableArray([{ firstName: "phil" }, { firstName: "person" }]);
this.selectedPerson = ko.observable("none selected");
}
selectUser(data){
console.log(this);
this.selectedPerson(data.firstName);
}
}
I have to provide a binding in the markup like so: <div data-bind="text: firstName, click: $parent.selectUser.bind($parent)">
but when i declare the click in the constructor I don't have to provide the context.
anybody know why?