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


TypeScript DOM.querySelectorAll方法代码示例

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


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

示例1: expect

             .then((rootTC) => {
               rootTC.componentInstance.booleanCondition = false;
               rootTC.detectChanges();
               expect(DOM.querySelectorAll(rootTC.nativeElement, 'copy-me').length).toEqual(0);
               expect(rootTC.nativeElement).toHaveText('');

               rootTC.componentInstance.booleanCondition = true;
               rootTC.detectChanges();
               expect(DOM.querySelectorAll(rootTC.nativeElement, 'copy-me').length).toEqual(1);
               expect(rootTC.nativeElement).toHaveText('hello');

               rootTC.componentInstance.nestedBooleanCondition = false;
               rootTC.detectChanges();
               expect(DOM.querySelectorAll(rootTC.nativeElement, 'copy-me').length).toEqual(0);
               expect(rootTC.nativeElement).toHaveText('');

               rootTC.componentInstance.nestedBooleanCondition = true;
               rootTC.detectChanges();
               expect(DOM.querySelectorAll(rootTC.nativeElement, 'copy-me').length).toEqual(1);
               expect(rootTC.nativeElement).toHaveText('hello');

               rootTC.componentInstance.booleanCondition = false;
               rootTC.detectChanges();
               expect(DOM.querySelectorAll(rootTC.nativeElement, 'copy-me').length).toEqual(0);
               expect(rootTC.nativeElement).toHaveText('');

               async.done();
             });
开发者ID:cedriclam,项目名称:angular,代码行数:28,代码来源:ng_if_spec.ts

示例2: expect

             .then((view) => {
               view.context.booleanCondition = false;
               view.detectChanges();
               expect(DOM.querySelectorAll(view.rootNodes[0], 'copy-me').length).toEqual(0);
               expect(DOM.getText(view.rootNodes[0])).toEqual('');

               view.context.booleanCondition = true;
               view.detectChanges();
               expect(DOM.querySelectorAll(view.rootNodes[0], 'copy-me').length).toEqual(1);
               expect(DOM.getText(view.rootNodes[0])).toEqual('hello');

               view.context.nestedBooleanCondition = false;
               view.detectChanges();
               expect(DOM.querySelectorAll(view.rootNodes[0], 'copy-me').length).toEqual(0);
               expect(DOM.getText(view.rootNodes[0])).toEqual('');

               view.context.nestedBooleanCondition = true;
               view.detectChanges();
               expect(DOM.querySelectorAll(view.rootNodes[0], 'copy-me').length).toEqual(1);
               expect(DOM.getText(view.rootNodes[0])).toEqual('hello');

               view.context.booleanCondition = false;
               view.detectChanges();
               expect(DOM.querySelectorAll(view.rootNodes[0], 'copy-me').length).toEqual(0);
               expect(DOM.getText(view.rootNodes[0])).toEqual('');

               async.done();
             });
开发者ID:AsherBarak,项目名称:angular,代码行数:28,代码来源:ng_if_spec.ts

示例3: expect

 tb.createView(TestComponent, {html: html}).then((view) => {
   view.detectChanges();
   expect(DOM.querySelectorAll(view.nodes[0], 'copy-me').length).toEqual(1);
   expect(DOM.getText(view.nodes[0])).toEqual('hello');
   view.context.numberCondition = 2;
   view.detectChanges();
   expect(DOM.querySelectorAll(view.nodes[0], 'copy-me').length).toEqual(1);
   expect(DOM.getText(view.nodes[0])).toEqual('hello');
   async.done();
 });
开发者ID:gdi2290,项目名称:sample-Angular2,代码行数:10,代码来源:if_spec.ts

示例4: queryBoundElements

export function queryBoundElements(templateContent: Node, isSingleElementChild: boolean):
    Element[] {
  var result;
  var dynamicElementList;
  var elementIdx = 0;
  if (isSingleElementChild) {
    var rootElement = DOM.firstChild(templateContent);
    var rootHasBinding = DOM.hasClass(rootElement, NG_BINDING_CLASS);
    dynamicElementList = DOM.getElementsByClassName(rootElement, NG_BINDING_CLASS);
    result = ListWrapper.createFixedSize(dynamicElementList.length + (rootHasBinding ? 1 : 0));
    if (rootHasBinding) {
      result[elementIdx++] = rootElement;
    }
  } else {
    dynamicElementList = DOM.querySelectorAll(templateContent, NG_BINDING_CLASS_SELECTOR);
    result = ListWrapper.createFixedSize(dynamicElementList.length);
  }
  for (var i = 0; i < dynamicElementList.length; i++) {
    result[elementIdx++] = dynamicElementList[i];
  }
  return result;
}
开发者ID:goderbauer,项目名称:angular,代码行数:22,代码来源:util.ts


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