Thomas Deutsch
Thomas Deutsch

Reputation: 2554

Knockout.js: View-Model function returns code?

Thanks to the great Tutorial from John Papa. I tried my best to implement the Revealing Module Pattern for my ViewModel using knockout.js

It is a very simple example:

http://jsfiddle.net/ThomasDeutsch/EHYfT/

Somehow I get not the value returned - but the code that is executed ? I expected to see the result "3" on the screen :)

What am I doing wrong?

Upvotes: 1

Views: 1548

Answers (1)

John Earles
John Earles

Reputation: 7194

You are adding two observables together. Observables are functions. Make sure you use the () form to get the actual value, like this:

addId = ko.computed(function () {
    return customer1.Id() + customer2.Id();
}),

Upvotes: 4

Related Questions