Search code examples
javascriptknockout.jsko.observablearray

Array change subscriptions returning undefined


Below is a small poc i was working on depicting various functionalities of knockout. I want to call the subscribe method for observableArray, but it returns undefined, i tried two different ways, i am unable to understand what is incorrect. any guidance welcome. I was referring to this article. here Array change subscriptions You can also find the both my jsfiddles below.

    self.cartList = ko.observableArray();
    self.cartList.subcribe(
    function (newValue) {
        console.log(ko.toJS(self.cartList));
    }, null, "arrayChange");

fiddle 1

fiddle 2


Solution

  • Simple typo -- you spelled subscribe wrong.

    self.cartList.subscribe(
    

    http://jsfiddle.net/jqq8y067/7/