title: How to set the background color of a select from the currently selected option using Angular 4
body: <p>I'm trying to set the background color of a select based on the currently selected option which contains its color.  I'm stuck on how to get the styling set (I'm using Angular 4).</p>
  
  <p>An example of what I'm trying to do is:</p>
  
  <pre><code>&lt;select class="form-control" [ngStyle]="this.options[this.selectedIndex].getAttribute('style')"
                          [(ngModel)]="result.Id"
                          name="test"
                          required&gt;
                      &lt;option *ngFor="let weight of riskWeights" [ngStyle]="{'background-color': weight.color}" [ngValue]="weight.Id"&gt;{{weight.name}}&lt;/option&gt;
                  &lt;/select&gt;
  </code></pre>
  
  <p>Where I'm going wrong is trying to get the currently selected item and setting the style:  [ngStyle]="this.options[this.selectedIndex].getAttribute('style')".  I can't get the syntax/technique right for reading the currently selected item's background color and apply it to the select.</p>
  
  <p>Any ideas on how to do this?</p>