1

I started learning AngularJS but had a little problem.... What is wrong here ? I try to declare songlist as an array with Song Objects but get an error to use "="

import { Song } from './song.model';

export class Chart
{
  id:number;
  chartName: string;
  img: string;
  createDate:string;

  songList[]: Song;

}

2 Answers 2

2

Your declartion is invalid, should be:

songList: Song[]

Sign up to request clarification or add additional context in comments.

Comments

2

Check out this typescript type definition for arrays.

https://www.typescriptlang.org/docs/handbook/basic-types.html

The syntax for typescript typecasting is

variable: type;

So for an array you'll want something like

songList: Array<Song>;

or

songList: Song[];

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.