我试过了:
import {Component, Template, bootstrap} from 'angular2/angular2';
import {Immutable} from 'immutable/immutable';
@Component({
selector: 'my-app'
})
@Template({
inline: '<h1>Hello {{ name }}</h1>'
})
class MyAppComponent {
constructor() {
this.name = 'Alice';
this.wishes = Immutable.List(['a dog', 'a balloon', 'and so much more']);
console.log(this.wishes);
}
}
bootstrap(MyAppComponent);
然后,Immutable最终被定义为未定义。 然后我试了一下:
import {Component, Template, bootstrap} from 'angular2/angular2';
import {Immutable} from 'immutable/immutable';
@Component({
selector: 'my-app'
})
@Template({
inline: '<h1>Hello {{ name }}</h1>'
})
class MyAppComponent {
constructor(im: Immutable) {
this.name = 'Alice';
this.wishes = im.List(['a dog', 'a balloon', 'and so much more']);
console.log(this.wishes);
}
}
然后我得到Cannot resolve all parameters for MyAppComponent
。任何人都可以帮我吗?
是的,我已将immutable
文件夹添加到System.paths
。可能是不可变的,不能以ES6的方式导入吗?
答案 0 :(得分:5)
Damnit,这是一个愚蠢的错误。我不得不改变
import {Immutable} from 'immutable/immutable';
到
import Immutable from 'immutable/immutable';