本文整理汇总了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();
});
示例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());
});
}
示例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();
});
示例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();
});
示例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);
}
}
}
}
示例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();
});
示例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);
});
示例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});
});