I'm encountering an error with the map method in my code, even after correctly importing 'rxjs/add/operator/map'. I've followed all the necessary steps and upgraded to rxjs 5.0.1, but the error persists. Do you have any suggestions on how to resolve this issue?
Below is a snippet of the sample code:
The problematic method causing the "Unresolved function or method" error:
import { Component, OnInit} from '@angular/core';
import { Router } from '@angular/router';
import { FormGroup, FormBuilder } from '@angular/forms';
import { Http, RequestOptions, Headers, Response } from '@angular/http';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/map';
import 'rxjs/Rx';
@Component({
moduleId: module.id,
templateUrl: 'navigation.component.html'
})
export class NavigationComponent implements OnInit {
form: FormGroup;
myInput = {input1:'',input2:'' }
webserviceUrl : "https://httpbin.org/get";
ngOnInit(): void { }
constructor(private router: Router) {}
constructor (private http: Http) {}
onRegister() {
let headers = new Headers({ 'Content-Type': 'application/json' });
let options = new RequestOptions({ headers: headers });
return this.http.post(this.webserviceUrl, options)
.map(this.myInput)
.catch(this.handleError);
}
private handleError (error: Response | any) {
let errMsg: string;
if (error instanceof Response) {
const body = error.json() || '';
const err = body.error || JSON.stringify(body);
errMsg = `${error.status} - ${error.statusText || ''} ${err}`;
} else {
errMsg = error.message ? error.message : error.toString();
}
console.error(errMsg);
return Observable.throw(errMsg);
}
}