문제

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:

  • There are 2 Customer objects.
  • Add the ID from both Objects and return it.

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?

도움이 되었습니까?

해결책

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();
}),
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top