当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript ObservableArray.push方法代码示例

本文整理汇总了TypeScript中tns-core-modules/data/observable-array.ObservableArray.push方法的典型用法代码示例。如果您正苦于以下问题:TypeScript ObservableArray.push方法的具体用法?TypeScript ObservableArray.push怎么用?TypeScript ObservableArray.push使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tns-core-modules/data/observable-array.ObservableArray的用法示例。


在下文中一共展示了ObservableArray.push方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: initDataItems

 private initDataItems() {
     this._sourceDataItems = new ObservableArray<DataItem>();
     for (let i = 0; i < posts.names.length; i++) {
         if (androidApplication) {
             this._sourceDataItems.push(new DataItem(i, posts.names[i], "This is item description", posts.titles[i], posts.text[i], "res://" + posts.images[i].toLowerCase()));
         }
         else {
             this._sourceDataItems.push(new DataItem(i, posts.names[i], "This is item description", posts.titles[i], posts.text[i], "res://" + posts.images[i]));
         }
     }
 }
开发者ID:telerik,项目名称:nativescript-ui-samples-angular,代码行数:11,代码来源:listview-dynamic-size-auto.component.ts

示例2: items

 get items(): ObservableArray<Item> {
   this._items = new ObservableArray<Item>();
   for (let i = 0; i < 100; i++){
     this._items.push(new Item(`Item`, i));
   }
   return this._items;
 }
开发者ID:sitefinitysteve,项目名称:NativeScript,代码行数:7,代码来源:main-view-model.ts

示例3:

            onDiscovered: (peripheral: any) => {
                // peripherals.push(observable.fromObject(peripheral));
                console.log('peripheral', JSON.stringify(peripheral));
                this.peripherals.push(observable.fromObject(peripheral));

                console.log('Size: ', this.peripherals.length);
            }
开发者ID:SmartTraceIO,项目名称:smarttrace-beacon,代码行数:7,代码来源:bluetooth.component.ts

示例4: function

export const test_ObservableArray_pushShouldAppendNewElementsFromSourceArray = function () {
    // >> observable-array-push-source
    const array = new ObservableArray([1, 2, 3]);
    // >> (hide)
    const viewBase = new Label();
    viewBase.set("testProperty", 0);
    viewBase.bind({ sourceProperty: "length", targetProperty: "testProperty" }, array);
    // << (hide)
    const result = array.push([4, 5, 6]);
    // << observable-array-push-source
    TKUnit.assert(result === 6 && array.getItem(5) === 6, "ObservableArray push() should append new elements from source array!");
    TKUnit.assert(viewBase.get("testProperty") === array.length, "Expected: " + array.length + ", Actual: " + viewBase.get("testProperty"));
};
开发者ID:sitefinitysteve,项目名称:NativeScript,代码行数:13,代码来源:observable-array-tests.ts

示例5: onAddItemClick

 public onAddItemClick() {
     const id = Math.round(Math.random() * 100);
     this._dataItems.push(new DataItem(id, "This is a new item: " + id, "This is the new item's description."));
 }
开发者ID:telerik,项目名称:nativescript-ui-samples-angular,代码行数:4,代码来源:listview-observable-array.component.ts

示例6: addItemsToSourceDataItems

 private addItemsToSourceDataItems(size: number) {
     for (let i = 0; i < size; i++) {
         this._sourceDataItems.push(this.getNextItemFromServer());
     }
 }
开发者ID:telerik,项目名称:nativescript-ui-samples-angular,代码行数:5,代码来源:listview-fixed-size-auto-with-small-source.component.ts


注:本文中的tns-core-modules/data/observable-array.ObservableArray.push方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。