本文整理汇总了TypeScript中@angular/core.Renderer2.appendChild方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Renderer2.appendChild方法的具体用法?TypeScript Renderer2.appendChild怎么用?TypeScript Renderer2.appendChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@angular/core.Renderer2
的用法示例。
在下文中一共展示了Renderer2.appendChild方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: ngAfterViewInit
ngAfterViewInit() {
this.preNode = this._renderer.createElement('pre');
this.codeNode = this._renderer.createElement('code');
this._renderer.addClass(this.codeNode, 'language-' + this.language);
this._renderer.appendChild(this.nativeElement, this.preNode);
this._renderer.appendChild(this.preNode, this.codeNode);
this.codeNode.textContent = this.code;
Prism.highlightElement(this.codeNode);
}
示例2: ngOnInit
ngOnInit() {
this.renderer.setStyle(
this.element.nativeElement, 'font-size','2em'
);
this.renderer.setStyle(
this.element.nativeElement, 'color','yellow'
);
this.renderer.addClass(this.element.nativeElement, 'ok')
const h1 = this.renderer.createElement('h1');
const text = this.renderer.createText('Click here to add h1');
this.renderer.appendChild(h1, text);
this.renderer.appendChild(this.element.nativeElement, h1);
}
示例3: ngOnInit
ngOnInit() {
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();
}
示例4: ngOnInit
ngOnInit() {
const iElement = this.renderer.createElement('i');
this.renderer.addClass(iElement, 'icon-prepend');
this.renderer.addClass(iElement, 'fa');
this.renderer.addClass(iElement, 'fa-clipboard');
this.renderer.appendChild(this.elementRef.nativeElement, iElement);
}
示例5: setLabel
setLabel(): void {
if (!this.floatingLabel) {
this.floatingLabel = this.renderer2.createElement('label');
this.renderer2.appendChild(this.hostNativeElement, this.floatingLabel);
}
this.floatingLabel.innerHTML = this.label;
}
示例6: ngOnInit
ngOnInit() {
this.inputElement = document.getElementById(this.cdPasswordButton);
this.iElement = this.renderer.createElement('i');
this.renderer.addClass(this.iElement, 'icon-prepend');
this.renderer.addClass(this.iElement, 'fa');
this.renderer.appendChild(this.el.nativeElement, this.iElement);
this.update();
}
示例7: initPopup
private initPopup({data, coord, component, onCloseCallback}: IPopupParam): void {
this.componentRef = this.componentFactoryResolver.resolveComponentFactory<DynamicPopup>(component).create(this.injector);
const popupComponent = this.componentRef.instance;
const domElem = (this.componentRef.hostView as EmbeddedViewRef<DynamicPopup>).rootNodes[0] as HTMLElement;
this.bindInputProps(popupComponent, data, coord);
this.bindOutputProps(popupComponent, domElem, onCloseCallback);
this.renderer.addClass(domElem, 'popup');
this.renderer.appendChild((this.appRef.components[0].location).nativeElement, domElem);
this.appRef.attachView(this.componentRef.hostView);
}
示例8: 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);
}
示例9: createScript
createScript(src: string, renderer: Renderer2, elmRef?: ElementRef, callback?: () => void): HTMLScriptElement {
const script = elmRef ? renderer.createElement('script') :
this.getOwnerDocument().createElement('script');
script.type = 'text/javascript';
script.src = src;
script.async = true;
script.charset = 'UTF-8';
script.id = `rebirth_script_${Math.random()}`;
if (callback) {
script.onreadystatechange = script.onload = () => {
if ((!script.readyState || /loaded|complete/.test(script.readyState))) {
callback();
}
};
}
renderer.appendChild(elmRef.nativeElement, script);
return script;
}
示例10: createRipple
createRipple(event) {
if (this.rippleContainer.firstChild) {
this.removeRipple();
}
const width = this.el.nativeElement.offsetWidth;
const height = this.el.nativeElement.offsetHeight;
const size = width > height ? width : height;
const pos = this.el.nativeElement.getBoundingClientRect();
const x = event.pageX - pos.left - (size / 2);
const y = event.pageY - pos.top - (size / 2);
const ripple = this.renderer.createElement('span');
const style = {
'top': y,
'left': x,
'height': size,
'width': size
};
this.setRippleStyle(style, ripple);
this.renderer.appendChild(this.rippleContainer, ripple);
}