How to get dropdown values through from angular api??
below shared my code, could u guys help me please
App.Component.ts
- constructor(private httpService: HttpClient){}
- myInsuredTypes: string[];
- selected = null;
-
- ngOnInit () {
- this.httpService.get('http://192.168.1.51/masterapi/api/GetInsurance').subscribe(
- data => {
- this.myInsuredTypes = data as string [];
- },
- (err: HttpErrorResponse) => {
- console.log (err.message);
- }
- );
- }
App.component.html
- <div style="float:left;padding:10px;margin:0 auto;">
- <select [(ngModel)]="selected">
- <option [(ngValue)]="description">{{description}}</option>
- </select>
-
- <p>{{ selected }}</p>
- </div>
App.module.ts
-
- import { HttpClientModule } from '@angular/common/http';
- import { FormsModule } from '@angular/forms';
Errors comes
Access to XMLHttpRequest at 'http://192.168.1.51/masterapi/api/GetInsurance/' from origin 'http://localhost:4200' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.