本文整理汇总了TypeScript中@angular/core.Renderer2.setAttribute方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Renderer2.setAttribute方法的具体用法?TypeScript Renderer2.setAttribute怎么用?TypeScript Renderer2.setAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@angular/core.Renderer2
的用法示例。
在下文中一共展示了Renderer2.setAttribute方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: inlineSvgContent
private inlineSvgContent(svg: SVGElement) {
const el = this.elementRef.nativeElement;
el.innerHTML = '';
if (this.scaleToContainer) {
this.renderer.setAttribute(svg, 'width', '100%');
this.renderer.setAttribute(svg, 'height', '100%');
this.renderer.setAttribute(svg, 'preserveAspectRatio', 'xMidYMid meet');
}
this.renderer.appendChild(el, svg);
}
示例2: ngOnChanges
public ngOnChanges(changes: SimpleChanges) {
if (this.mdlBadgeContent === null || typeof this.mdlBadgeContent === 'undefined'){
this.renderer.removeAttribute(this.el, DATA_BADE_ATTR);
return;
}
this.renderer.setAttribute(this.el, DATA_BADE_ATTR, this.mdlBadgeContent);
}
示例3: it
it('unknown', () => {
const div = document.createElement('div');
expect(div.hasAttribute('unknown:name')).toBe(false);
renderer.setAttribute(div, 'name', 'value', 'unknown');
expect(div.getAttribute('unknown:name')).toBe('value');
});
示例4: constructor
constructor(private element: ElementRef,
private renderer: Renderer2,
private hostService: HostService,
private cd: ChangeDetectorRef) {
this.renderer.addClass(this.element.nativeElement, 'slds-popover');
this.renderer.addClass(this.element.nativeElement, 'slds-popover_tooltip');
this.renderer.setAttribute(this.element.nativeElement, 'role', 'tooltip');
}
示例5: ngOnInit
ngOnInit() {
this.renderer.setAttribute(this.elementRef.nativeElement, 'tabindex', '-1');
this.iElement = this.renderer.createElement('i');
this.renderer.addClass(this.iElement, 'icon-prepend');
this.renderer.addClass(this.iElement, 'fa');
this.renderer.appendChild(this.elementRef.nativeElement, this.iElement);
this.update();
}
示例6: shouldSetAttributeWithNs
function shouldSetAttributeWithNs(namespace: string): void {
const namespaceUri = NAMESPACE_URIS[namespace];
const div = document.createElement('div');
expect(div.hasAttributeNS(namespaceUri, 'name')).toBe(false);
renderer.setAttribute(div, 'name', 'value', namespace);
expect(div.getAttributeNS(namespaceUri, 'name')).toBe('value');
}
示例7: nglOnPropertyChange
nglOnPropertyChange(prop) {
if (prop === 'uid') {
this.renderer.setAttribute(this.element.nativeElement, 'id', this.uid);
} else if (prop === 'placement') {
this.nubbin = POSITION_MAP[this.placement].nubbin;
this.setHostClass();
} else if (prop === 'template') {
this.cd.markForCheck();
}
}
示例8: constructor
constructor(
el: ElementRef,
renderer: Renderer2,
private settings: SettingsService,
private router: Router,
private titleSrv: TitleService,
private modalSrv: NzModalService,
) {
renderer.setAttribute(
el.nativeElement,
'ng-alain-version',
VERSION_ALAIN.full,
);
renderer.setAttribute(
el.nativeElement,
'ng-zorro-version',
VERSION_ZORRO.full,
);
}
示例9: ngOnInit
ngOnInit() {
if(this.inputAttribut.code == '00100020' && this.inputAttribut.externalInternalAetMode == "external"){
this.renderer.setAttribute(this.el.nativeElement, 'placeholder', this.inputAttribut.name);
}else{
if ((this.inputAttribut.code in Globalvar.IODPLACEHOLDERS) && _.hasIn(Globalvar.IODPLACEHOLDERS[this.inputAttribut.code], this.inputAttribut.mode)){
if (Globalvar.IODPLACEHOLDERS[this.inputAttribut.code][this.inputAttribut.mode].action === 'replace' && this.el.nativeElement.tagName === 'INPUT'){
this.renderer.setAttribute(this.el.nativeElement, 'placeholder', Globalvar.IODPLACEHOLDERS[this.inputAttribut.code][this.inputAttribut.mode].placeholder);
this.renderer.setAttribute(this.el.nativeElement, 'title', Globalvar.IODPLACEHOLDERS[this.inputAttribut.code][this.inputAttribut.mode].placeholder);
}
if (Globalvar.IODPLACEHOLDERS[this.inputAttribut.code][this.inputAttribut.mode].action === 'disable'){
this.disableElement();
}
}else{
if (this.inputAttribut.iod && !_.hasIn(this.inputAttribut.iod, this.inputAttribut.code)){
this.disableElement();
}
this.renderer.setAttribute(this.el.nativeElement, 'placeholder', this.inputAttribut.name);
}
}
}
示例10: setAttributes
private setAttributes(tries: number = 0) {
if (tries > 20) { return; }
if (this.field.attributes && this.field.attributes.length > 0) {
if (this.input && this.input.nativeElement) {
for (const attr of this.field.attributes) {
this.renderer.setAttribute(this.input.nativeElement, attr.name, attr.value);
}
} else {
this.timeout('set_attributes', () => this.setAttributes(++tries));
}
}
}