我正在尝试使用Angular2、system.js和typescript。到目前为止,我导出的接口一切正常,但是一旦我尝试导入一个枚举类型,就会出现问题。在下面的代码中,Card
没有问题,但是当我导入Legend
时,就会出现错误:GET http://localhost:3000/shared/legend 404 (Not Found)
。
import {Component, OnInit} from 'angular2/core';
import {CardService} from './card.service';
import {Card} from '../../shared/card';
import {Legend} from '../../shared/legend';
@Component({
selector: 'cards-list',
templateUrl: 'app/cards-list.html',
providers: [CardService]
})
export class CardsListComponent implements OnInit {
public cards:Card[];
//using Legend is the problem!
public legendValues:String[] = [Legend[Legend.ARIANE]];
constructor(private _cardService:CardService) {
}
getCards() {
this._cardService.getCards(cards => this.cards = cards);
}
ngOnInit() {
this.getCards();
}
}
这是传说文件:
export enum Legend {
THE_RAPTOR,
LINZA,
ARIANE,
OZAN
}
为什么我不能导入普通枚举?