4

我试过了:

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. 难道 Immutable 不能以 ES6 的方式导入吗?

4

1 回答 1

5

这是一个小错误。我不得不改变

import {Immutable} from 'immutable/immutable';

import Immutable from 'immutable/immutable';
于 2015-04-09T00:39:11.600 回答