進口: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' ;並說它會工作,但不是在我的情況。
看起來你寫錯了:retur => {。改變它返回 – eg16
返回只是我想的一個變量。不要以爲它會影響錯誤 –