-2

我试图在 angular7 中使用 web api 获取数据,但我面临 [object object] 问题。

auth.service.ts

getCareer(){
    return this._HttpClient.get('http://localhost:49345/api/website/getCarrier');
    }

组件.ts

export class careerComponent implements OnInit{

    getCareer$: object;

     constructor(private _AuthService: AuthService){ }

     ngOnInit(){
        this._AuthService.getCareer().subscribe(
        data => this.getCareer$ = data
    );
    }


}

组件.html

<div class="col-xl-6" *ngFor="let career of getCareer$">
                    <h2>test</h2>
                    <h3>{{career.designation}}</h3>
                </div>

问题/控制台屏幕截图

在此处输入图像描述

API 截图

在此处输入图像描述

我该如何解决?

4

1 回答 1

0
`ngOnInit(){
    this._AuthService.getCareer().subscribe(
    data => { this.getCareer$ = data.data.map(item => {
            return item.designation
         })
});
}`

如上所述更改代码..希望它会起作用。现在 getCareer$ 包含所有名称

于 2018-10-29T12:57:29.453 回答