title: How To Change Background Color In Hex Dynamically in Angular2?
body: <p>Converting decimal value to hex value in Angular to change <code>background-color</code> dynamically. Here is the component    </p>
  
  <pre><code>import { Component } from '@angular/core';
  
      @Component({
        selector: 'my-app',
        template: `
  
          &lt;h1&gt;Change Background Color Dynamically&lt;/h1&gt;
  
          &lt;!-- Chang Background Color By Increasing Or Decreasing Color Value --&gt;
          &lt;button (click)="bgColor = bgColor + 15"&gt;+&lt;/button&gt;
          &lt;button (click)="bgColor = bgColor - 15"&gt;-&lt;/button&gt;
  
          &lt;div [ngStyle]="{'background-color': '#' + bgColor}"&gt;
            Changable Background Color
         &lt;/div&gt;
  
        `
      })
  
      export class AppComponent { 
  
          bgColor;
  
        constructor() { 
          this.bgColor = 'BBFFFF';
        }
  
      }
  </code></pre>