Working with Angular 8 , I have problem in my logic.
There are two drop downs:
First Drop down
The options in the first drop down is shown from an array of objects
Example Code, ts:
{rs_id: "a5f100d5-bc88-4456-b507-1161575f8819",
rs_code: "100006",
rs_name: "Leanbox Logistics Solutions Pvt Ltd"} ,
{rs_id: "a5f100d5-bc88-4456-b507-116157523345",
rs_code: "123406",
rs_name: "xysa Solutions Pvt Ltd"} ,
{rs_id: "a5f100456-b507-116157523345",
rs_code: "123406223",
rs_name: "Solutions Pvt Ltd"} ,
]
html
<option>
<select (change)="getRsId($event)" >
<option [value]='data.rs_id' *ngFor='let data of s_rsList ; let i = index'> {{data.rs_name}} </option>
</select>
- options in second drop down is shown from same array of objects , but object selected in the first dropdown should be removed from Array .
Full code example:
slackbliz link ->
https://stackblitz.com/edit/angular-7lgyfe?file=src%2Fapp%2Fapp.component.html
html
<div>
<p> First DropDown </p>
<select (change)="getRsId($event)" >
<option [value]='data.rs_id' *ngFor='let data of s_rsList ; let i = index'> {{data.rs_name}} </option>
</select>
<p> Second DropDown </p>
<select (change)="getRsId($event)" >
<option [value]='data.rs_id' *ngFor='let data of r_rsList ; let i = index'> {{data.rs_name}} </option>
</select>
</div>
ts
import { Component } from '@angular/core';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
export class AppComponent {
name = 'Angular';
s_rsList :any = [
{rs_id: "a5f100d5-bc88-4456-b507-1161575f8819",
rs_code: "100006",
rs_name: "Leanbox Logistics Solutions Pvt Ltd"} ,
{rs_id: "a5f100d5-bc88-4456-b507-116157523345",
rs_code: "123406",
rs_name: "xysa Solutions Pvt Ltd"} ,
{rs_id: "a5f100456-b507-116157523345",
rs_code: "123406223",
rs_name: "Solutions Pvt Ltd"} ,
]
r_rsList : any = []
constructor(){}
getRsId(value){
console.log(value);
let Rsindex = value.target['selectedIndex'];
console.log(Rsindex);
this.r_rsList.splice(Rsindex, 1);
}
}