return FALSE; $r = well_tag_thread__update(array('id' => $id), $update); return $r; } function well_tag_thread_find($tagid, $page, $pagesize) { $arr = well_tag_thread__find(array('tagid' => $tagid), array('id' => -1), $page, $pagesize); return $arr; } function well_tag_thread_find_by_tid($tid, $page, $pagesize) { $arr = well_tag_thread__find(array('tid' => $tid), array(), $page, $pagesize); return $arr; } ?>javascript - Type {...} is missing the following properties from type 'any[]': length,pop,push,concat, and 28 mo
最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin12浏览0评论

I have this error:

    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-ponent',
  templateUrl: './album-ponent.ponent.html',
  styleUrls: ['./album-ponent.ponent.css']
})
export class AlbumComponentComponent implements OnInit {

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

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

}

What am I doing wrong? Thank you in advanvce!

Share Improve this question asked Mar 2, 2022 at 16:46 MaxMax 1191 gold badge1 silver badge8 bronze badges 1
  • Either your json is an object, so it won't have those properties that are array properties, or your json data needs to be parsed first anyway in order to use it as array. What do you get when you console.log the albumData? – Misha Mashina Commented Mar 2, 2022 at 16:55
Add a ment  | 

2 Answers 2

Reset to default 9
 album:any=[]; 

use this code instead of the code you have added

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./demo/how-to-read-local-json-file-in-angular

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论