为什么 service get id 总是“未定义”?

时间:2021-07-01 06:23:49

标签: angular codeigniter crud

为什么 service get id 总是“undefined”?在邮递员那里工作时,我在这里使用 angular?

  **MY API
  base_path = "http://localhost:8080/rest4/public/api/mobile";
  
    **moudule.ts
  
  ngOnInit(): void {
    this.find(this.activatedRoute.snapshot.paramMap.get[this.id]);
    //mengambil detail mahasiswa sesuai nim yang di kirim
    this.mahasiswaService.find(this.id).subscribe((res) => {
      this.parseData(res);
    });
  }

  parseData(res) {
    for (var i = 0; i < res.length; i++) {
      if (res[i] != undefined) {
        this.id = res[i];
      }
    }
  }
  
  
  **service.ts
  
  find(id: any): Observable<any> {
    return this.http.get(
      this.base_path + "/find/" + JSON.stringify(id)
    ) as Observable<GHS[]>;
  }

Module.ts

enter image description here

Service.ts

enter image description here

邮递员

enter image description here

结果

enter image description here

0 个答案:

没有答案