javascript - ko.observableArray() not adding elements - Stack Overflow

I'm trying out KO but have problems getting observableArray to work, the code is very simple​var t

I'm trying out KO but have problems getting observableArray to work, the code is very simple

​var test = new ko.observableArray();
var regulararray = [];

test.push("item");
regulararray.push("regularpush");
console.log("the length for ko: " + test.length + " the length for regular array: " +    regulararray.length);​​

For some reason the length of the knockout array is 0 while the regular array length is 1.

Why is this happening?

I'm trying out KO but have problems getting observableArray to work, the code is very simple

​var test = new ko.observableArray();
var regulararray = [];

test.push("item");
regulararray.push("regularpush");
console.log("the length for ko: " + test.length + " the length for regular array: " +    regulararray.length);​​

For some reason the length of the knockout array is 0 while the regular array length is 1.

Why is this happening?

Share Improve this question asked Mar 28, 2012 at 6:38 MixitrixiMixitrixi 1571 silver badge10 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 11

use test().length instead of test.length

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744607694a4583568.html

相关推荐

  • javascript - ko.observableArray() not adding elements - Stack Overflow

    I'm trying out KO but have problems getting observableArray to work, the code is very simple​var t

    1天前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信