當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript ObservableArray.splice方法代碼示例

本文整理匯總了TypeScript中tns-core-modules/data/observable-array.ObservableArray.splice方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript ObservableArray.splice方法的具體用法?TypeScript ObservableArray.splice怎麽用?TypeScript ObservableArray.splice使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在tns-core-modules/data/observable-array.ObservableArray的用法示例。


在下文中一共展示了ObservableArray.splice方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: function

export const test_ObservableArray_spliceShouldRemoveAndInertSpecifiedNumberOfElementsStartingFromSpecifiedIndexAndRaiseChangeEventWithCorrectArgs = function () {
    let result: ChangedData<number>;

    // >> observable-array-splice-args-change
    const array = new ObservableArray(["one", "two", "three"]);

    array.on(ObservableArray.changeEvent, (args: ChangedData<number>) => {
        // Argument (args) is ChangedData<T>.
        // args.eventName is "change".
        // args.action is "splice".
        // args.index is the start index.
        // args.removed.length is equal to the number of deleted items.
        // args.addedCount is equal to the delta between number of inserted items and number of deleted items but not less than 0.

        // >> (hide)
        result = args;
        // << (hide)
    });

    array.splice(1, 2, "six", "seven", "eight");
    // << observable-array-splice-args-change

    TKUnit.assert(result.eventName === ObservableArray.changeEvent && result.action === ChangeType.Splice &&
        result.removed.length === 2 && result.index === 1 && result.addedCount === 1, "ObservableArray splice() should raise 'change' event with correct args!");
};
開發者ID:sitefinitysteve,項目名稱:NativeScript,代碼行數:25,代碼來源:observable-array-tests.ts

示例2: addMoreItemsFromSource

 public addMoreItemsFromSource(chunkSize: number) {
     let newItems = this._sourceDataItems.splice(0, chunkSize);
     this.dataItems.push(newItems);
 }
開發者ID:telerik,項目名稱:nativescript-ui-samples-angular,代碼行數:4,代碼來源:listview-dynamic-size-auto.component.ts

示例3: onRemoveItemClick

 public onRemoveItemClick() {
     this._dataItems.splice(this._dataItems.length - 1, 1);
 }
開發者ID:telerik,項目名稱:nativescript-ui-samples-angular,代碼行數:3,代碼來源:listview-observable-array.component.ts


注:本文中的tns-core-modules/data/observable-array.ObservableArray.splice方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。