本文整理汇总了TypeScript中angular2/src/core/facade/collection.ListWrapper.clear方法的典型用法代码示例。如果您正苦于以下问题:TypeScript ListWrapper.clear方法的具体用法?TypeScript ListWrapper.clear怎么用?TypeScript ListWrapper.clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类angular2/src/core/facade/collection.ListWrapper
的用法示例。
在下文中一共展示了ListWrapper.clear方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should detect changes in list', () => {
let l = [];
differ.check(l);
l.push('a');
differ.check(l);
expect(differ.toString())
.toEqual(
iterableChangesAsString({collection: ['a[null->0]'], additions: ['a[null->0]']}));
l.push('b');
differ.check(l);
expect(differ.toString())
.toEqual(iterableChangesAsString(
{collection: ['a', 'b[null->1]'], previous: ['a'], additions: ['b[null->1]']}));
l.push('c');
l.push('d');
differ.check(l);
expect(differ.toString())
.toEqual(iterableChangesAsString({
collection: ['a', 'b', 'c[null->2]', 'd[null->3]'],
previous: ['a', 'b'],
additions: ['c[null->2]', 'd[null->3]']
}));
ListWrapper.removeAt(l, 2);
differ.check(l);
expect(differ.toString())
.toEqual(iterableChangesAsString({
collection: ['a', 'b', 'd[3->2]'],
previous: ['a', 'b', 'c[2->null]', 'd[3->2]'],
moves: ['d[3->2]'],
removals: ['c[2->null]']
}));
ListWrapper.clear(l);
l.push('d');
l.push('c');
l.push('b');
l.push('a');
differ.check(l);
expect(differ.toString())
.toEqual(iterableChangesAsString({
collection: ['d[2->0]', 'c[null->1]', 'b[1->2]', 'a[0->3]'],
previous: ['a[0->3]', 'b[1->2]', 'd[2->0]'],
additions: ['c[null->1]'],
moves: ['d[2->0]', 'b[1->2]', 'a[0->3]']
}));
});