本文整理匯總了TypeScript中@angular/core/src/debug/debug_node.DebugElement.queryAll方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript DebugElement.queryAll方法的具體用法?TypeScript DebugElement.queryAll怎麽用?TypeScript DebugElement.queryAll使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類@angular/core/src/debug/debug_node.DebugElement
的用法示例。
在下文中一共展示了DebugElement.queryAll方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: getChildrenBySelector
/**
* Gets a child DebugElement by css selector.
*
* The child of DebugElement are other elements that are "known" to
* Angular.
*/
static getChildrenBySelector(parent: DebugElement, selector: string): DebugElement[] {
const results = [];
parent.queryAll(By.css(selector)).forEach((el) => results.push(el));
parent.children.forEach((de) => {
TestHelper.getChildrenBySelector(de, selector).forEach((el) => results.push(el));
});
return results;
}
示例2: it
it('should show only accept button', () => {
dialogService.alert({
header: '',
message: ''
});
fixture.detectChanges();
const buttons = de.queryAll(By.css('p-dialog button'));
expect(buttons.length).toBe(1);
});
示例3: fakeAsync
fakeAsync(() => {
spyOn(component, 'onClickConfirm');
dialogService.confirm({
header: '',
message: ''
});
fixture.detectChanges(); // ngIf
tick();
fixture.detectChanges(); // confirmation service make it happen
const buttons = de.queryAll(By.css('p-confirmDialog button'));
buttons[0].nativeElement.click();
expect(component.onClickConfirm).toHaveBeenCalledTimes(1);
buttons[1].nativeElement.click();
expect(component.onClickConfirm).toHaveBeenCalledTimes(2);
})