Не удается найти другой поддерживающий объект '[object Object]' типа 'object'. NgFor поддерживает только привязку к итерациям, таким как массивы. в angular7 - PullRequest
0 голосов
/ 29 октября 2018

Я пытаюсь получить данные с помощью веб-API в Angular7, но я сталкиваюсь с проблемой [объект объекта].

auth.service.ts

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

component.ts

export class careerComponent implements OnInit{

    getCareer$: object;

     constructor(private _AuthService: AuthService){ }

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


}

component.html

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

Проблема / консольный скриншот

enter image description here

Скриншот API

enter image description here

Как я могу это решить?

1 Ответ

0 голосов
/ 29 октября 2018
`ngOnInit(){
    this._AuthService.getCareer().subscribe(
    data => { this.getCareer$ = data.data.map(item => {
            return item.designation
         })
});
}`

измените код, как указано выше ... надеюсь, он будет работать. теперь getCareer $ содержит все обозначения

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...