本文整理汇总了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