I am new to Angular 4. I have a variable "md_id" which is binded to the view as follows.
HTML:
<tr *ngFor="let item of driverData">
<td class="align-right" id="md_id" [(ngModel)]="item.md_id" name="driverId" ngDefaultControl (click)="runPromo()">{{item.driver_name}}
</td>
</tr>
JSON:
[{"md_id": 1, "driver_name": "A"}, {"md_id": 2, "driver_name": "B"}, {"md_id": 3, "driver_name": "C"}, {"md_id": 4, "driver_name": "D"}]
I want that based on the value of md_id selected, it should pass that particular value of md_id to another service that can display the results accordingly based upon the selection.
The selected value of md_id should be passed to the following service.
Service:
public getName(md_id){
return this.http.get(url+'/api/names?md_id='+md_id)
.map((resService: Response) => resService.json())
}
Component:
this.calendarService.getName(this.md_id).subscribe(data => this.promoName = data);
Could you please help me in knowing how can I pass the value of one service binded in the view to be passed into another service.
Am I missing here something?
Please help.