2016-11-17 39 views
0

进口:Angular2,地产 '地图' 上不类型存在 '可观测'

import { Component,OnInit } from '@angular/core'; 
import { FormGroup, FormControl, Validators, FormBuilder } from '@angular/forms'; 
import { Application } from './Application'; 
import { Http, Response } from '@angular/http'; 
import { NgModule } from '@angular/core'; 
import { Headers } from '@angular/http'; 
import 'rxjs/add/operator/map'; 
import 'rxjs/Rx'; 

的方法:

saveApplcation() { 
    var application = new Application(); 
    application.ssnr = this.form.value.ssnr; 
    application.loanamount = this.form.value.amount; 
    application.email = this.form.value.email; 
    application.phonenumber = this.form.value.phonenumber; 
    application.repaymenttime = this.form.value.time; 

    var body: string = JSON.stringify(application); 
    var headers = new Headers({ "Content-Type": "application/json" }); 

    this._http.post("api/Application/", body, { headers: headers }) 
     .map(returnData => returnData.toString()) 
     .subscribe(
     retur => { 
      this.showForm = false; 
      this.showMenu = true; 
     }, 
     error => alert(error), 
     () => console.log("done post-api/loan") 
     ); 

}; 

错误说:TS2339地产 '地图' 上不存在键入'Observable'。 TypeScript虚拟项目C:\ Users \ kim \ Documents \ Visual Studio 2015 \ Projects \ NewOblig3 \ NewOblig3 \ app \ app.component.ts 52活动

我见过人们导入'rxjs/add/operator/map' ;并说它会工作,但不是在我的情况。

+0

看起来你写错了:retur => {。改变它返回 – eg16

+0

返回只是我想的一个变量。不要以为它会影响错误 –

回答

1

从早期的测试版升级后,我一直有同样的问题。我的问题(我怀疑你的)在配置文件package.json和systemjs.config.js中。老实说,我不是100%确定解决问题的确切线条,但特别是systemjs.config.js的格式完全不同。

我推荐的解决方案是使用Quick Start Tutorial这两个配置文件替换您自己的然后运行npm install

我更新了这些之后,我并不需要修复import 'rxjs/add/operator/map';;一切工作正常。

注意:在进行这些更改之前,您应该备份这些文件,以确保不会丢失自定义设置,并且可能会由升级造成其他问题。

相关问题