I have an Angular application which gets data from a web api. I also have a form in my page, which has a hidden field which needs to send the value from that api: number
. I have tried the following code but it is not working:
ts.component file.
receivedIncident: any;
number: any;
constructor(private service: nowService,
private appComponent: AppComponent,
private userService: UserService,
private router: Router,
private http: HttpClient,
private route: ActivatedRoute
) {
this.receivedIncident = { number: '', opened_at: '', description: '', short_description: ''}; this.receivedLocation = {city:null, country: null}
}
private getIncident() {
this.service.getIncident(this.s_id, this.c_id).subscribe((data) => {
this.loading = true;
console.log('Result - ', data);
console.log('incident data is received');
this.loading = true;
this.receivedIncident = data.result[0];
})
}
ngOnInit() {
this.loading = true;
this.getIncident();
this.loading = true;
})
this.addCommentsForm = new FormGroup({
comment: new FormControl(''),
c_id: new FormControl(this.customer_id),
number: new FormControl(this.receivedIncident.number),
})
}
html form field
<input name="number" class="form-input" type="hidden" id="number" value="number
Any ideas?