首页 > 解决方案 > 在我的控制器数组中检索 1 个变量

问题描述

我的控制器返回一个变量数组。

    return response()->json([$newBauxEnCours, $bienPrixEnBaisse]);

我调用 API Laravel 的方法

 getProducts(status: string, typeTransac: string): Observable <any> {

        let params = new HttpParams();

    params = params.append('status', status);
    params = params.append('typeTransac', typeTransac);

    console.log(params);
    
    if (status !== null && typeTransac !== null) {
    // Conversion en nombre 
    return this.apiClient.get(this.ApiUrl, { params: params});
    }else{
        console.log('aucune valeur en params')
    }
}

ngOnInit(){
    this.ArchiveVente$ = this.dataMlsService.getProducts('Vendu', 'Vente');
    console.log(this.ArchiveVente$);
  }

我的问题是:为什么要在 Angular 中检索我的变量 $newBauxEnCours ?

谢谢

标签: arraysangularlaravelhttpclient

解决方案


试试这样

ngOnInit(){
    this.dataMlsService.getProducts('Vendu', 'Vente').subscribe((response: any)=> {
     console.log(response);
    });
   
  }

推荐阅读