當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。