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


TypeScript DOM.querySelector方法代码示例

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


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

示例1: it

    it('can show feed', () => {
      const cmp:Feed = cmpDebugElement.componentInstance;
      expect(cmp.feed.length).toEqual(2);

      const el = cmpDebugElement.nativeElement;
      expect(DOM.querySelectorAll(el, 'li .content').length).toEqual(2);

      const avatarLink = DOM.querySelector(el, 'li>a');
      expect(avatarLink.getAttribute('href')).toEqual('/users/1');

      const gravatarDebugElement = cmpDebugElement.query(By.directive(Gravatar));
      expect(gravatarDebugElement).toBeTruthy();
      expect(gravatarDebugElement.componentInstance.email).toEqual('test1@test.com');
      expect(gravatarDebugElement.componentInstance.alt).toEqual('test user1');

      const userLink = DOM.querySelector(el, '.user>a');
      expect(userLink).toHaveText('test user1');
      expect(userLink.getAttribute('href')).toEqual('/users/1');

      const content = DOM.querySelector(el, '.content');
      expect(content).toHaveText('content1');

      const timestamp = DOM.querySelector(el, '.timestamp');
      expect(timestamp.innerText).toMatch(/1 day ago/);

      const deleteLinks = DOM.querySelectorAll(el, '.delete');
      expect(deleteLinks[0]).toBeTruthy();
      expect(deleteLinks[1]).toBeFalsy();
    });
开发者ID:windwang,项目名称:angular2-app,代码行数:29,代码来源:Feed.spec.ts

示例2: ngAfterViewInit

    ngAfterViewInit():void {
        this.selectInput = $(DOM.querySelector(this.el.nativeElement,'select'));

        let divParent:any = $(DOM.querySelector(this.el.nativeElement,'.input-field'));
        divParent.on('change', 'select', () => {
            this.onChangeValue();
            this.updateValue(this.selectInput.val());
        });
    }
开发者ID:RGZINC,项目名称:swagger2-angular2-materialize,代码行数:9,代码来源:materialize-select.ts

示例3: expect

           tcb.overrideTemplate(TestComponent, html).createAsync(TestComponent).then((fixture) => {
             fixture.detectChanges();
             DOM.addClass(DOM.querySelector(fixture.debugElement.nativeElement, 'copy-me'), 'foo');

             fixture.debugElement.componentInstance.numberCondition = 2;
             fixture.detectChanges();
             expect(DOM.hasClass(
                        DOM.querySelector(fixture.debugElement.nativeElement, 'copy-me'), 'foo'))
                 .toBe(true);

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

示例4: expect

               .then((fixture) => {
                 fixture.detectChanges();
                 DOM.addClass(DOM.querySelector(fixture.debugElement.nativeElement, 'copy-me'),
                              "foo");

                 fixture.debugElement.componentInstance.numberCondition = 2;
                 fixture.detectChanges();
                 expect(
                     DOM.hasClass(DOM.querySelector(fixture.debugElement.nativeElement, 'copy-me'),
                                  "foo"))
                     .toBe(true);

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

示例5: setupToggleAria

  setupToggleAria() {
    let toggleTypes = ['md-switch', 'md-checkbox'];
    let toggle;
    let el = this._element.nativeElement;

    for (var i = 0, toggleType; toggleType = toggleTypes[i]; ++i) {
      if (toggle = DOM.querySelector(el, toggleType)) {
        if (!toggle.hasAttribute('aria-label')) {
          var p = DOM.querySelector(el, 'p');
          if (!p) return;
          toggle.setAttribute('aria-label', 'Toggle ' + p.textContent);
        }
      }
    }
  }
开发者ID:AEKurt,项目名称:ng2-material,代码行数:15,代码来源:list.ts

示例6: it

 it('shows a nav link to logout', () => {
   const link = DOM.querySelector(cmpDebugElement.nativeElement, '#navbar li.logout>a');
   expect(link).toBeTruthy();
   spyOn(loginService, 'logout');
   link.click();
   expect(loginService.logout).toHaveBeenCalled();
 });
开发者ID:gtostock,项目名称:angular2-app,代码行数:7,代码来源:Header.spec.ts

示例7: it

 it('deletes micropost when confirmed', () => {
   const cmp:MicropostList = cmpDebugElement.componentInstance;
   const deleteLink = DOM.querySelector(cmpDebugElement.nativeElement, '.delete');
   spyOn(window, 'confirm').and.returnValue(true);
   deleteLink.click();
   expect(cmp.posts.length).toEqual(1);
 });
开发者ID:windwang,项目名称:angular2-app,代码行数:7,代码来源:MicropostList.spec.ts

示例8: it

 it('can load more', () => {
   const cmp:UserList = cmpDebugElement.componentInstance;
   const moreBtn = DOM.querySelector(cmpDebugElement.nativeElement, '.moreBtn');
   spyOn(cmp, 'listProvider').and.callThrough();
   moreBtn.click();
   expect(cmp.users.length).toEqual(4);
   expect(cmp.listProvider).toHaveBeenCalledWith({maxId: 100, count: 5});
 });
开发者ID:gtostock,项目名称:angular2-app,代码行数:8,代码来源:UserList.spec.ts


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