当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript ListWrapper.clear方法代码示例

本文整理汇总了TypeScript中angular2/src/facade/collection.ListWrapper.clear方法的典型用法代码示例。如果您正苦于以下问题:TypeScript ListWrapper.clear方法的具体用法?TypeScript ListWrapper.clear怎么用?TypeScript ListWrapper.clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在angular2/src/facade/collection.ListWrapper的用法示例。


在下文中一共展示了ListWrapper.clear方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: it

 it('should handle swapping element', () => {
   l = [1, 2];
   changes.check(l);
   ListWrapper.clear(l);
   ListWrapper.push(l, 2);
   ListWrapper.push(l, 1);
   changes.check(l);
   expect(changes.toString()).toEqual(iterableChangesAsString({
     collection: ['2[1->0]', '1[0->1]'],
     previous: ['1[0->1]', '2[1->0]'],
     moves: ['2[1->0]', '1[0->1]']
   }));
 });
开发者ID:gdi2290,项目名称:sample-Angular2,代码行数:13,代码来源:iterable_changes_spec.ts

示例2: it

      it('should detect changes in list', () => {
        let l = [];
        changes.check(l);

        l.push('a');
        changes.check(l);
        expect(changes.toString())
            .toEqual(
                iterableChangesAsString({collection: ['a[null->0]'], additions: ['a[null->0]']}));

        l.push('b');
        changes.check(l);
        expect(changes.toString())
            .toEqual(iterableChangesAsString(
                {collection: ['a', 'b[null->1]'], previous: ['a'], additions: ['b[null->1]']}));

        l.push('c');
        l.push('d');
        changes.check(l);
        expect(changes.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);
        changes.check(l);
        expect(changes.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');
        changes.check(l);
        expect(changes.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]']
            }));
      });
开发者ID:AsherBarak,项目名称:angular,代码行数:50,代码来源:iterable_changes_spec.ts

示例3: redistributeNodes

function redistributeNodes(contents, nodes) {
  for (var i = 0; i < contents.length; ++i) {
    var content = contents[i];
    var select = content.select;
    var matchSelector = (n) => DOM.elementMatches(n, select);
    if (select.length === 0) {
      content.insert(nodes);
      ListWrapper.clear(nodes);
    } else {
      var matchingNodes = ListWrapper.filter(nodes, matchSelector);
      content.insert(matchingNodes);
      ListWrapper.removeAll(nodes, matchingNodes);
    }
  }
}
开发者ID:gdi2290,项目名称:sample-Angular2,代码行数:15,代码来源:light_dom.ts

示例4: redistributeNodes

// Projects the light DOM into the shadow DOM
function redistributeNodes(contents: List<Content>, nodes: List</*node*/ any>) {
  for (var i = 0; i < contents.length; ++i) {
    var content = contents[i];
    var select = content.select;

    // Empty selector is identical to <content/>
    if (select.length === 0) {
      content.insert(ListWrapper.clone(nodes));
      ListWrapper.clear(nodes);
    } else {
      var matchSelector = (n) => DOM.elementMatches(n, select);
      var matchingNodes = ListWrapper.filter(nodes, matchSelector);
      content.insert(matchingNodes);
      ListWrapper.removeAll(nodes, matchingNodes);
    }
  }
  for (var i = 0; i < nodes.length; i++) {
    var node = nodes[i];
    if (isPresent(node.parentNode)) {
      DOM.remove(nodes[i]);
    }
  }
}
开发者ID:B-Thapa,项目名称:angular,代码行数:24,代码来源:light_dom.ts


注:本文中的angular2/src/facade/collection.ListWrapper.clear方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。