31
votes

I am using Angular 2.

When I use either of these two, my program runs well:

import { BehaviorSubject } from 'rxjs/Rx';
import { BehaviorSubject } from 'rxjs';

However, I try to use the following way:

import { BehaviorSubject } from 'rxjs/subject/BehaviorSubject';

But I failed, my browser console shows:

Uncaught Error: Cannot find module 'rxjs/subject/BehaviorSubject'

How can I use third way correctly? Thanks

1
Could you provide the way you configure rxjs in your main HTML file? Thanks!Thierry Templier
@ThierryTemplier haha, same again. Actually I am using angular2-meteor, so I don't have those stuff..Hongbo Miao
I have a look at the rxjs source (Rx.js) and I can see the module registration: System.register("rxjs/subject/BehaviorSubject", .... Any hints about the used version? ;-)Thierry Templier
@ThierryTemplier oh, I don't know where to check my RxJS exact version.. I only know it is RxJS 5..Hongbo Miao

1 Answers

82
votes
import {BehaviorSubject} from 'rxjs/BehaviorSubject';

rxjs 6.x

import {BehaviorSubject} from 'rxjs';

See also