如何将不可变的js导入angular 2(alpha)?

问题描述 投票:4回答:1

我尝试过:

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);

但是不可变最终会变得不确定。然后我尝试:

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方式导入不可变?

javascript angular ecmascript-6 immutable.js
1个回答
5
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.