我想嘗試從 json 文件 url 加載國(guó)家: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 函數(shù)從我用這里的 url 創(chuàng)建的服務(wù)獲取數(shù)據(jù)就是服務(wù) 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); } }此顯示數(shù)據(jù):在控制臺(tái)日志中未定義。請(qǐng)幫我解決
從 json 文件填充國(guó)家到 angular2-multiselect
aluckdog
2022-12-09 16:48:17