本文整理匯總了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('');
});