I have a drop-down list that currently displays objects in arrayed fashion. The JSON data comes from a service which is injected into the component. I filter the data according to iso_id and upon selecting an option from the drop-down, I display the filtered data. I'm trying to display this data only when a button (Array) is clicked after selecting the respective option. Right now, selecting an option from drop down displays the data and clicking on the Array button makes it disappear. How do I pass this data into the button click? Here's some sample code-
HTML
<md-select [(ngModel)]="selectedISO" (ngModelChange)="onSelect(selectedISO)" placeholder="TSO" [(ngModel)]="containerDisplay" >
<md-option value="Charge Only" > Charge Only </md-option>
<md-option value="PJM" >PJM </md-option>
<md-option value="Not in ISO Market" > Not in ISO Market </mdoption>
<md-option value="UCSD"> UCSD </md-option>
</md-select>
<button md-button (click)="onClickArray(selectedISO)" [(ngModel)]="containerDisplay" ngDefaultControl>
Array
</button>
<div class="ui-ivs-container" *ngIf="containerDisplay" >
<div class="ui-ivs-resources">
<div *ngFor="let resource of isoToShow; let i = index;"
[ngClass]="{...}">
//Array of objects gets displayed//
</div>
</div>
My TS file looks like this-
@Component({
selector: 'app-home',
templateUrl: './home.component.html',
styleUrls: ['./home.component.scss']
})
export class HomeComponent implements OnInit {
containerDisplay:boolean;
selectedISO;
constructor(private service: Service) {
this.isoToShow=this.isoArray; // gets populated by subscribing to service
}
onSelect(val){
console.log(val);
this.onClickArray(val);
}
onClickArray(val){
this.isoToShow=this.isoArray.filter(resource => resource.iso_id===val)
}
}