5

I've tried:

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

But then Immutable ends up being undefined. Then I tried:

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

But then I get Cannot resolve all parameters for MyAppComponent. Can anybody help me with this? And yes I've added the immutable folder to System.paths. Could it be that Immutable just can't be imported in an ES6 kind of way?

1
  • How do you tell Angular that your data is immutable? Commented May 8, 2015 at 19:27

1 Answer 1

5

It was a small mistake. I had to change

import {Immutable} from 'immutable/immutable';

to

import Immutable from 'immutable/immutable';
Sign up to request clarification or add additional context in comments.

1 Comment

If you use JSPM as package manager you need to import * as Immutable from 'immutable'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.