本文整理汇总了TypeScript中angular2/src/platform/dom/dom_adapter.DOM.getText方法的典型用法代码示例。如果您正苦于以下问题:TypeScript DOM.getText方法的具体用法?TypeScript DOM.getText怎么用?TypeScript DOM.getText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类angular2/src/platform/dom/dom_adapter.DOM
的用法示例。
在下文中一共展示了DOM.getText方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: expect
.then((fixture) => {
fixture.detectChanges();
expect(DOM.querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
.toEqual(3);
expect(DOM.getText(fixture.debugElement.nativeElement))
.toEqual('helloNumberhelloStringhelloFunction');
fixture.debugElement.componentInstance.numberCondition = 0;
fixture.detectChanges();
expect(DOM.querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
.toEqual(1);
expect(fixture.debugElement.nativeElement).toHaveText('helloString');
fixture.debugElement.componentInstance.numberCondition = 1;
fixture.debugElement.componentInstance.stringCondition = "bar";
fixture.detectChanges();
expect(DOM.querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
.toEqual(1);
expect(fixture.debugElement.nativeElement).toHaveText('helloNumber');
async.done();
});
示例2: stringifyElement
export function stringifyElement(el): string {
var result = '';
if (DOM.isElementNode(el)) {
var tagName = DOM.tagName(el).toLowerCase();
// Opening tag
result += `<${tagName}`;
// Attributes in an ordered way
var attributeMap = DOM.attributeMap(el);
var keys = [];
attributeMap.forEach((v, k) => { keys.push(k); });
keys.sort();
for (let i = 0; i < keys.length; i++) {
var key = keys[i];
var attValue = attributeMap.get(key);
if (!isString(attValue)) {
result += ` ${key}`;
} else {
result += ` ${key}="${attValue}"`;
}
}
result += '>';
// Children
var children = DOM.childNodes(DOM.templateAwareRoot(el));
for (let j = 0; j < children.length; j++) {
result += stringifyElement(children[j]);
}
// Closing tag
if (!ListWrapper.contains(_singleTagWhitelist, tagName)) {
result += `</${tagName}>`;
}
} else if (DOM.isCommentNode(el)) {
result += `<!--${DOM.nodeValue(el)}-->`;
} else {
result += DOM.getText(el);
}
return result;
}
示例3: inferEventName
private inferEventName() {
if (this.isCommand()) return DOM.getText(this.el) || DOM.getValue(this.el);
return DOM.getProperty(this.el, 'id') || DOM.getProperty(this.el, 'name') || DOM.tagName(this.el);
}