本文整理匯總了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!");
};
示例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