September 2017
Intermediate to advanced
450 pages
11h 24m
English
The Renderer service in Angular is useful for doing direct user interface manipulation while still taking advantage of Angular's sophisticated event handling and data-binding. For example, this component uses the Renderer service to add a style to our component's element that will turn all our text blue:
import {Component, Renderer, ElementRef} from '@angular/core';@Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css']})export class AppComponent { constructor(private renderer: Renderer, </span>private element: ElementRef) {}; ngOnInit() { this.renderer.setElementStyle(this.element.nativeElement, 'color', 'blue') }}
This feature will continue to work in Angular ...
Read now
Unlock full access