隐式上下文未定义,角7(implicit context is undefined, angular

2019-10-28 16:31发布

右,所以我遍历的信息的阵列和信息显示,我希望它的方式,但是,我得到一些amaing在寻找我的控制台错误: ERROR TypeError: "_v.context.$implicit is undefined"

API服务:

private extractData(res: Response) {
    let body = res;
    return body || {};
  }

  getWeather(city: string, isoCode: string): Observable<any> {
    return this.http.get(`${this.endPoint}${city},${isoCode}${this.constants.apiKey}`)
    .pipe(map(this.extractData));
  }

部件使用API​​服务:

  theWeather:any = [];
  countryList = COUNTRIES;
  isLoading: boolean = true;
  showWeather: boolean = false;

  constructor(private apiCall:ApiService) { }


  ngOnInit() {
    this.retrieveWeather()
  };

  retrieveWeather() {
    console.log('COUNTRY LIST', this.countryList);

    this.theWeather = [];
    this.countryList.map((element, i) => {
      this.apiCall.getWeather(element.city, element.countryIso)
        .subscribe((data: {}) => {
          element.weatherInfo = data;
        });
        this.isLoading = false;
      });
      this.showWeather = true;
  };

和HTML文件:

<div class="country-container">
  <div *ngIf="isLoading">
    <mat-card>
      <mat-progress-spinner class="spinner-style" color="primary" mode="indeterminate"></mat-progress-spinner>
    </mat-card>
  </div>
  <div *ngIf="showWeather" class="card-container">
    <mat-card *ngFor="let c of countryList" class="card">
      <mat-card-title>Weather for: {{c.city}}, {{c.countryName}}</mat-card-title>
      <mat-card-content>The current weather is: {{c.weatherInfo.weather[0].description}}</mat-card-content>
    </mat-card>

  </div>
</div>

终于我的控制台的图像:

感谢您的帮助!

编辑:做标题更具体的问题。

Answer 1:

根据我的第五元件上(它表示线路10的索引4(这是元件5))在列表中它不能获取天气预报...检查坏请求参数和/或错误的返回数据。 删除临时元素或检查一下,看看是否错误“移动”。 也许最好的办法是检查不确定的,即使没有HTTP错误。



文章来源: implicit context is undefined, angular 7