Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

119
Visualizações
Type {...} is missing the following properties from type 'any[]': length,pop,push,concat, and 28 more

I have this error:

    Type {...} is missing the following properties from type 'any[]': length,pop,push,concat, and 28 more

I'm assigning album variable to the albumData array. Here is the code:

import { Component, OnInit } from '@angular/core';
import albumData from '../data/SearchResultsAlbum.json';

@Component({
  selector: 'app-album-component',
  templateUrl: './album-component.component.html',
  styleUrls: ['./album-component.component.css']
})
export class AlbumComponentComponent implements OnInit {

  album:Array<any>=[];
  
  constructor() { }

  ngOnInit(): void {
    
    this.album=albumData;
  }

}

What am I doing wrong? Thank you in advanvce!

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

 album:any=[]; 

use this code instead of the code you have added

about 4 years ago · Juan Pablo Isaza Relatório

0

By default, Angular doesn't read the JSON file in the application. So we need to do some extra stuff for that. So we will create a file named 'json-typings.d.ts' inside the app folder of the project.

declare module "*.json" {
const value: any;
export default value;
}

source: https://jsonworld.com/demo/how-to-read-local-json-file-in-angular

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda