@okrime

Как исправить ошибку?

TS2696: The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead?
Type 'Object' is missing the following properties from type 'Profile[]': length, pop, push, concat, and 29 more.

Код:

import { ProfileService } from './data/services/profile.service';
import { Component, inject } from '@angular/core';
import { RouterOutlet } from '@angular/router';
import { ProfileCardComponent } from "./common-ui/profile-card/profile-card.component";
import { Profile } from './data/interfaces/profile.interface';

@Component({
selector: 'app-root',
standalone: true,
imports: [RouterOutlet, ProfileCardComponent],

templateUrl: './app.component.html',
styleUrl: './app.component.scss'
})
export class AppComponent {
title = 'tik-talk';
profileService = inject(ProfileService);

profiles: Profile[] = [];

constructor() {
this.profileService.getTestAccounts()
.subscribe( val => {
this.profiles = val;
})
}
}
  • Вопрос задан
  • 21 просмотр
Пригласить эксперта
Ответы на вопрос 1
@visirok
Заходите на мою страницу www.sirotin.eu
Возможно, что val у вас «просто объект», в ожидается массив.
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы