jxycms
6/6/2018 - 3:34 AM

manipulate dropdown list and checkbox

HTML:

***** Always select last one ,when add a new one, this list will select new one automatically *****

<div>
    <label>Summary: </label>
    <select (change)="filterForeCasts($event.value)">
        <option *ngFor="let summary of summaries" [value]="summary" [selected]="summary == summaries[summaries.length-1]">
            {{summary}}
        </option>
        <option value="add">Add New Summary</option>
    </select>
</div>

Component:

filterForeCasts(filterVal: any) {
  if (filterVal == "0")
    this.forecasts = this.cacheForecasts;
  else
    this.forecasts = this.cacheForecasts.filter((item) => item.summary == filterVal);
}


checkbox

<input id="priceAlert" class="notify-checkbox" type="checkbox" [checked]="priceAlert" (change)="priceAlert = !priceAlert">