本文整理汇总了TypeScript中@angular/platform-browser.By.all方法的典型用法代码示例。如果您正苦于以下问题:TypeScript By.all方法的具体用法?TypeScript By.all怎么用?TypeScript By.all使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@angular/platform-browser.By
的用法示例。
在下文中一共展示了By.all方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('The second element should be focused', fakeAsync(() => {
const fix = TestBed.createComponent(SetFocusComponent);
fix.detectChanges();
const secondElem: HTMLElement = fix.debugElement.queryAll(By.all())[1].nativeElement;
tick(16);
fix.detectChanges();
expect(document.activeElement).toBe(secondElem);
}));
示例2: it
it('should trigger the methods in the action buttons', () => {
const primarySpy = jasmine.createSpy('spy');
const secondarySpy = jasmine.createSpy('spy2');
const options = {
secondary: [
{
label: 'Group Actions 1',
model: [
{
command: primarySpy,
icon: 'fa fa-refresh',
label: 'Action 1-1'
}
]
},
{
label: 'Group Actions 2',
model: [
{
command: secondarySpy,
icon: 'fa fa-refresh',
label: 'Action 2-1'
}
]
}
]
};
comp.options = options;
comp.selectedItems = [{ key: 'value' }, { key: 'value' }];
const actionButton: DebugElement = de.query(By.css('.action-header__secondary-button'));
actionButton.triggerEventHandler('click', {});
fixture.detectChanges();
const splitButtons = de.query(By.all()).nativeElement.querySelectorAll('.ui-menuitem-link');
const primaryButton = splitButtons[0];
const secondaryButton = splitButtons[1];
primaryButton.click();
secondaryButton.click();
expect(primarySpy).toHaveBeenCalled();
expect(secondarySpy).toHaveBeenCalled();
});
示例3:
import {DebugElement} from '@angular/core';
import {By} from '@angular/platform-browser';
var debugElement: DebugElement;
class MyDirective {}
// #docregion by_all
debugElement.query(By.all());
// #enddocregion
// #docregion by_css
debugElement.query(By.css('[attribute]'));
// #enddocregion
// #docregion by_directive
debugElement.query(By.directive(MyDirective));
// #enddocregion
示例4: it
it('should create the component', () => {
expect(component).toBeTruthy();
const node = fixture.debugElement.query(By.all());
expect(node.name).toEqual('img');
});
示例5: it
it('should create the component', () => {
expect(component).toBeTruthy();
const node = fixture.debugElement.query(By.all());
expect(node.nativeElement.innerHTML).not.toEqual('');
});