I'm trying to create a provider to simply return an array. I'm fairly new to Angular and am not sure what I'm doing wrong here, but I'm getting the following error:
'[ts] A computed property name must be of type 'string', 'number', 'symbol', or 'any'.'
Can anyone see what the issue?
import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import 'rxjs/add/operator/map';
@Injectable()
export class StatesProvider {
states:{};
constructor(public http: Http) {
console.log('Hello StatesProvider Provider');
}
getStates(){
this.states = {[
{
"name": "Alabama",
"abbreviation": "AL"
},
{
"name": "Alaska",
"abbreviation": "AK"
},
{
"name": "American Samoa",
"abbreviation": "AS"
},
{
"name": "Arizona",
"abbreviation": "AZ"
},
{
"name": "Arkansas",
"abbreviation": "AR"
},
{
"name": "California",
"abbreviation": "CA"
}
... (etc)
]
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…