Rahul Kumar

Rahul Kumar

  • NA
  • 43
  • 9.3k

event.data.indexOf is not a function in angular 2

May 21 2018 2:56 AM
HTML Code:
  1. <select class="form-select style-1 selectbox" sb="48771331" style="display: none;" formControlName="AutoID">  
  2. <option selected="0" value="0">---Select Country---</option>  
  3. <option *ngFor="let cd of countryData" value={{cd.AutoID}}>  
  4. {{cd.Name}}  
  5. </option>  
  6. </select>  
Component.ts:
  1. ngOnInit() {  
  2. debugger;  
  3. this.GetCountryList();  
  4. }  
  5. GetCountryList() {  
  6. this.loading = true;  
  7. this.schoolAddsService.GetCountryList()  
  8. .subscribe(data => {  
  9. this.loading = false;  
  10. this.countryData=data;  
  11. console.log(this.countryData);  
  12. },  
  13. error => {  
  14. console.log("Error :: " + error);  
  15. this.loading = false;  
  16. }  
  17. )  
  18. }  
Service.ts:
  1. export class SchoolAddsService{  
  2. constructor(private http: Http) { }  
  3. GetCountryList() {  
  4. return this.http.get(environment.apiPath + 'Country/GetCountries')  
  5. .map((res: Response) => res.json())  
  6. .catch(this.handleError)  
  7. }  
  8. private handleError(error: Response) {  
  9. return Observable.throw(error.statusText);  
  10. }  
  11. }