I have problem, my Knockout ViewModel is NO function and this IS NEEDED:
vmNeu = {
KdLand: ko.observableArray(),
SelectedKdLand: ko.observable(),
Ansprechpartner: ko.observableArray([]),
ApListe: ko.computed({
read: function() {
var apList = [];
$(this.Ansprechpartner()).each(function(index, ap) {
var vollerName = ap.Vorname + ' ' + ap.Nachname;
if (ap.IstStandard) {
vollerName += ' (Standard)';
}
apList.push({ label: vollerName, value: ap.AnsprechpartnerNr });
});
return apList;
}
})
};
Everything until now worked great, observables and subscriptions, but now I want to use an computed and I cant access an other property from my viewModel, I tried everything ;(
Is there a possibility?
Best regards
If you look on the docs for computed observables, you’ll see that
ko.computedtakes an argument for the scope ofthis. Try changing your code so it works like in the examples and it should work