Posts

Showing posts from April, 2018

Angular 4 Equal height divs / columns using Renderer2

We can make use of the Renderer2 library in Angular 4 to manipulate DOM elements. For example, we could equalize the heights of 2 divs / columns using Renderer2. Basically, what we're going to do is to obtain references to the DOM elements that we want to manipulate and then change the desired property value using Renderer2. 1. Obtain References to the DOM elements. In the HTML view, declare the divs as named templates, like so: < div class = "first-div" # first ></ div> < div class = "second-div" # second ></ div> Now, in the component, we can access references(ElementRefs) to them using @ViewChild. The component code should look like the following: import { Component , OnInit , ViewChild , ElementRef } from "@angular/core" ; export class Component implements OnInit { @ ViewChild ( "first" ) first ; @ ViewChild ( "second" ) second ; } 2....