本文整理汇总了TypeScript中angular2/src/dom/dom_adapter.DOM.querySelectorAll方法的典型用法代码示例。如果您正苦于以下问题:TypeScript DOM.querySelectorAll方法的具体用法?TypeScript DOM.querySelectorAll怎么用?TypeScript DOM.querySelectorAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类angular2/src/dom/dom_adapter.DOM
的用法示例。
在下文中一共展示了DOM.querySelectorAll方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: expect
.then((rootTC) => {
rootTC.componentInstance.booleanCondition = false;
rootTC.detectChanges();
expect(DOM.querySelectorAll(rootTC.nativeElement, 'copy-me').length).toEqual(0);
expect(rootTC.nativeElement).toHaveText('');
rootTC.componentInstance.booleanCondition = true;
rootTC.detectChanges();
expect(DOM.querySelectorAll(rootTC.nativeElement, 'copy-me').length).toEqual(1);
expect(rootTC.nativeElement).toHaveText('hello');
rootTC.componentInstance.nestedBooleanCondition = false;
rootTC.detectChanges();
expect(DOM.querySelectorAll(rootTC.nativeElement, 'copy-me').length).toEqual(0);
expect(rootTC.nativeElement).toHaveText('');
rootTC.componentInstance.nestedBooleanCondition = true;
rootTC.detectChanges();
expect(DOM.querySelectorAll(rootTC.nativeElement, 'copy-me').length).toEqual(1);
expect(rootTC.nativeElement).toHaveText('hello');
rootTC.componentInstance.booleanCondition = false;
rootTC.detectChanges();
expect(DOM.querySelectorAll(rootTC.nativeElement, 'copy-me').length).toEqual(0);
expect(rootTC.nativeElement).toHaveText('');
async.done();
});
示例2: expect
.then((view) => {
view.context.booleanCondition = false;
view.detectChanges();
expect(DOM.querySelectorAll(view.rootNodes[0], 'copy-me').length).toEqual(0);
expect(DOM.getText(view.rootNodes[0])).toEqual('');
view.context.booleanCondition = true;
view.detectChanges();
expect(DOM.querySelectorAll(view.rootNodes[0], 'copy-me').length).toEqual(1);
expect(DOM.getText(view.rootNodes[0])).toEqual('hello');
view.context.nestedBooleanCondition = false;
view.detectChanges();
expect(DOM.querySelectorAll(view.rootNodes[0], 'copy-me').length).toEqual(0);
expect(DOM.getText(view.rootNodes[0])).toEqual('');
view.context.nestedBooleanCondition = true;
view.detectChanges();
expect(DOM.querySelectorAll(view.rootNodes[0], 'copy-me').length).toEqual(1);
expect(DOM.getText(view.rootNodes[0])).toEqual('hello');
view.context.booleanCondition = false;
view.detectChanges();
expect(DOM.querySelectorAll(view.rootNodes[0], 'copy-me').length).toEqual(0);
expect(DOM.getText(view.rootNodes[0])).toEqual('');
async.done();
});
示例3: expect
tb.createView(TestComponent, {html: html}).then((view) => {
view.detectChanges();
expect(DOM.querySelectorAll(view.nodes[0], 'copy-me').length).toEqual(1);
expect(DOM.getText(view.nodes[0])).toEqual('hello');
view.context.numberCondition = 2;
view.detectChanges();
expect(DOM.querySelectorAll(view.nodes[0], 'copy-me').length).toEqual(1);
expect(DOM.getText(view.nodes[0])).toEqual('hello');
async.done();
});
示例4: queryBoundElements
export function queryBoundElements(templateContent: Node, isSingleElementChild: boolean):
Element[] {
var result;
var dynamicElementList;
var elementIdx = 0;
if (isSingleElementChild) {
var rootElement = DOM.firstChild(templateContent);
var rootHasBinding = DOM.hasClass(rootElement, NG_BINDING_CLASS);
dynamicElementList = DOM.getElementsByClassName(rootElement, NG_BINDING_CLASS);
result = ListWrapper.createFixedSize(dynamicElementList.length + (rootHasBinding ? 1 : 0));
if (rootHasBinding) {
result[elementIdx++] = rootElement;
}
} else {
dynamicElementList = DOM.querySelectorAll(templateContent, NG_BINDING_CLASS_SELECTOR);
result = ListWrapper.createFixedSize(dynamicElementList.length);
}
for (var i = 0; i < dynamicElementList.length; i++) {
result[elementIdx++] = dynamicElementList[i];
}
return result;
}