ThierryDD
4/16/2018 - 12:51 PM

Carousel Component TS - Iteration 3 - Album Height

 import { Component, OnInit, Input, ElementRef } from '@angular/core';

 // ...

 @Component({
   // ...
 })
 export class CarouselComponent implements OnInit {

   // ...
   @Input() ratio: number = 0.75;
   albumHeight: number;

   // ...

   ngOnInit() {
     // ...
     this.albumHeight = this.ratio * this.elRef.nativeElement.clientWidth;
     this.elRef.nativeElement.style.setProperty('--album-height', this.albumHeight + "px");
   }

 }