简体   繁体   中英

Custom Pipe Filter For Array Of Json Objects In Angular 4

I have an array, that consists a list of json objects as items. I am using this array as an options list for two select controls, here I want to hide first select control selected items in second select control options list.

Is it possible to do?

I don't know why are you looking for a pipe/filter solution when it can be done so easily without pipe? I may not be knowing entire scenario of yours but what you have written according to that a simple solution would be,

<select class="form-control" [(ngModel)]="selectedCity">
     <option *ngFor="let ct of cities" [value]="ct.id">{{ct.name}}  
</select>



// look at [disabled]="selectedCity==ct.id"

 <select class="form-control" [(ngModel)]="selectedOtherCity">
     <option [disabled]="selectedCity==ct.id" *ngFor="let ct of cities" [value]="ct.id">{{ct.name}}  
</select>

detailed code could be found here : https://plnkr.co/edit/gkvFqtyddLVEsFOE07Ls?p=preview

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM