Created
June 19, 2018 06:34
-
-
Save chriskavanagh/e50f69ab24d0c92d269310f9fae0ae6c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, OnInit } from '@angular/core'; | |
import { ElementRef, Renderer2 } from '@angular/core'; | |
@Component({ | |
selector: 'app-fancy-form', | |
templateUrl: './fancy-form.component.html', | |
styleUrls: ['./fancy-form.component.css'] | |
}) | |
export class FancyFormComponent implements OnInit { | |
constructor(private renderer: Renderer2, private el: ElementRef) { } | |
ngOnInit() { | |
const div = this.renderer.createElement('div'); | |
const text = this.renderer.createText('Hello world!'); | |
this.renderer.appendChild(div, text); | |
this.renderer.appendChild(this.el.nativeElement, div); | |
this.renderer.setStyle(this.el.nativeElement, 'font-size', '35px'); | |
this.renderer.setStyle(this.el.nativeElement, 'color', 'blue'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Renderer2 ex. in Angular-6. For reference only.