If you are not importing 'rxjs/all', then the Rxjs package is modularized
and you need to "add in" each function you want. I suggest you do NOT
import the 'all' module as this will bloat your application significantly.

Example:
import {Observable} from 'rxjs/Observable';
import 'rxjs/add/operator/toPromise'; // this adds the non-static
'toPromise' operator
import 'rxjs/add/operator/map';         // this adds the non-static 'map'
operator

-Luke




On Mon, Jul 25, 2016 at 9:20 AM, Alejandro C <[email protected]> wrote:

> I have the same problem... any suggestion?
>
> El lunes, 4 de julio de 2016, 8:29:49 (UTC-5), Abhishek Sharma escribió:
>>
>> // publisher.service.ts
>>
>> import { Injectable } from '@angular/core';
>> import { Publisher } from './publisher';
>>
>> import { Headers, Http, HTTP_PROVIDERS, Response, RequestOptions } from
>> '@angular/http';
>> import { Observable } from 'rxjs/Observable';
>> import 'rxjs/Rx';
>> import 'rxjs/add/operator/toPromise';
>>
>> @Injectable()
>> export class PublisherService{
>>    private publishersUrl = 'app/publisher';
>>
>>    constructor(private http: Http) { }
>>
>>     getPublishers(): Promise<Publisher[]>{
>>         return this.http.get(this.publishersUrl)
>>                    .toPromise()
>>                    .then(response => response.json().data)
>>                    .catch(this.handleError);
>>     }
>>
>>     private handleError(error: any) {
>>       console.error('An error occurred', error);
>>       return Promise.reject(error.message || error);
>>     }
>>
>> }
>>
>> Added following to main.ts and app.component.ts too to try and resolve
>> error:-
>>
>> import { Observable } from 'rxjs/Observable';
>> import 'rxjs/Rx';
>> import 'rxjs/add/operator/toPromise';
>>
>>
>> package.json:-
>>
>> {
>>   "name": "angular2-seed",
>>   "version": "1.0.0",
>>   "scripts": {
>>     "lite": "lite-server",
>>     "postinstall": "typings install",
>>     "gulp": "gulp",
>>     "start": "concurrently \"npm run gulp\" \"npm run lite\" ",
>>     "typings": "typings"
>>   },
>>   "license": "MIT",
>>   "dependencies": {
>>     "@angular/common": "2.0.0-rc.4",
>>     "@angular/compiler": "2.0.0-rc.4",
>>     "@angular/core": "2.0.0-rc.4",
>>     "@angular/http": "2.0.0-rc.4",
>>     "@angular/platform-browser": "2.0.0-rc.4",
>>     "@angular/platform-browser-dynamic": "2.0.0-rc.4",
>>     "@angular/router": "3.0.0-beta.1",
>>     "@angular/router-deprecated": "2.0.0-rc.2",
>>     "@angular/upgrade": "2.0.0-rc.4",
>>     "angular2-in-memory-web-api": "0.0.14",
>>     "systemjs": "0.19.27",
>>     "bootstrap": "^3.3.6",
>>     "es6-shim": "^0.35.0",
>>     "reflect-metadata": "^0.1.3",
>>     "rxjs": " 5.0.0-beta.6",
>>     "zone.js": "^0.6.12"
>>   },
>>   "devDependencies": {
>>     "concurrently": "^2.0.0",
>>     "gulp": "^3.9.0",
>>     "gulp-autoprefixer": "^3.1.0",
>>     "gulp-clean-css": "^2.0.6",
>>     "gulp-sass": "^2.3.1",
>>     "gulp-sourcemaps": "^1.6.0",
>>     "gulp-typescript": "^2.10.0",
>>     "lite-server": "^2.2.0",
>>     "systemjs-builder": "^0.15.16",
>>     "typescript": "^1.8.10",
>>     "typings":"^1.0.4"
>>   }
>> }
>>
>>
>> systemjs.config.js:-
>>
>> (function(global) {
>>
>>     // map tells the System loader where to look for things
>>     var map = {
>>         'app':                        'app', // 'dist',
>>         'rxjs':                       'node_modules/rxjs',
>>         'angular2-in-memory-web-api':
>> 'node_modules/angular2-in-memory-web-api',
>>         '@angular':                   'node_modules/@angular',
>>         '@angular/router':            'node_modules/@angular/router'
>>     };
>>
>>     // packages tells the System loader how to load when no filename
>> and/or no extension
>>     var packages = {
>>         'app':                        { main: 'boot.js',
>>  defaultExtension: 'js' },
>>         'rxjs':                       { defaultExtension: 'js' },
>>         'angular2-in-memory-web-api': { main: 'index.js',
>> defaultExtension: 'js' }
>>     };
>>
>>     var packageNames = [
>>         '@angular/common',
>>         '@angular/compiler',
>>         '@angular/core',
>>         '@angular/http',
>>         '@angular/platform-browser',
>>         '@angular/platform-browser-dynamic',
>>         '@angular/router',
>>         '@angular/router-deprecated',
>>         '@angular/testing',
>>         '@angular/upgrade'
>>     ];
>>
>>     // add package entries for angular packages in the form
>> '@angular/common': { main: 'index.js', defaultExtension: 'js' }
>>     packageNames.forEach(function(pkgName) {
>>         packages[pkgName] = { main: 'index.js', defaultExtension: 'js' };
>>     });
>>
>>
>>     var config = {
>>         map: map,
>>         packages: packages
>>     };
>>
>>     // filterSystemConfig - index.html's chance to modify config before
>> we register it.
>>     if (global.filterSystemConfig) { global.filterSystemConfig(config); }
>>
>>     System.config(config);
>>
>> })(this);
>>
>>
> --
> You received this message because you are subscribed to the Google Groups
> "AngularJS" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/angular.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Lucas Lacroix
Computer Scientist
System Technology Division, MEDITECH <http://ehr.meditech.com>
781-774-2293

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to