我想嘗試從 json 文件 url 加載國家:https : //raw.githubusercontent.com/sagarshirbhate/Country-State-City-Database/master/Contries.json 到 angular2-multiselect。下面是我的代碼getCountries(){this.country.allCountries().subscribe( data2 => { this.countryInfo = data2.Countries.CountryName; console.log('Data:', this.countryInfo); }, err => console.log(err), () => console.log('complete') )}所以 getcountry 函數從我用這里的 url 創建的服務獲取數據就是服務 export class CountriesService { url: string = "https://raw.githubusercontent.com/sagarshirbhate/Country-State-City- Database/master/Contries.json"; constructor(private http: HttpClient) { } allCountries(): Observable<any>{ return this.http.get(this.url); } }此顯示數據:在控制臺日志中未定義。請幫我解決
從 json 文件填充國家到 angular2-multiselect
aluckdog
2022-12-09 16:48:17