import { Component , OnInit , HostBinding , Input , ElementRef , ChangeDetectionStrategy , ChangeDetectorRef } from '@angular/core' ; import { UpdateHostClassService } from 'ngx-tethys/core' ; type IconNavTypes = 'primary' | 'secondary' | 'individual' | '' ; @ Component ( { selector : 'thy-icon-nav' , templateUrl : './icon-nav.component.html' , providers : [ UpdateHostClassService ] , changeDetection : ChangeDetectionStrategy . OnPush } ) export class ThyIconNavComponent implements OnInit { private initialized = false ; type : IconNavTypes ; @ HostBinding ( `class.thy-icon-nav` ) isIconNav = true ; @ Input ( ) set thyType ( type ) { this . type = type ; this . updateClasses ( ) ; this . changeDetectorRef . markForCheck ( ) ; } private updateClasses ( bypassInitialized ? ) { if ( ! bypassInitialized && ! this . initialized ) { return ; } this . updateHostClassService . updateClass ( this . type ? [ `thy-icon-nav-${ this . type }` ] : [ ] ) ; } constructor ( private updateHostClassService , private changeDetectorRef , elementRef ) { this . updateHostClassService . initializeElement ( elementRef ) ; } ngOnInit ( ) { this . initialized = true ; this . updateClasses ( true ) ; } }