I am getting an 'unresolved function' error for a .map in an ionic 2 RC0 project.
The code looks like this:
import {Injectable} from '@angular/core';
import {Events} from 'ionic-angular';
import {Http, RequestOptions} from '@angular/http';
import {API_ENDPOINT} from '../app_settings';
import {DjangoAuth} from '../providers/djangoAuth';
import 'rxjs/add/operator/map';
@Injectable()
export class ImageData {
userID:number = 0;
data:any;
httpBody:any;
constructor(public http: Http, public events: Events, public djangoAuth: DjangoAuth) {
}
loadImages(theUserID, numberItemsToGet, feedType){
var additional_parameters = '';
var theCategoriesWanted = 'ALL';
if (feedType == 'USERS'){
additional_parameters = '&fromthisuser=true';
theCategoriesWanted = 'ALL';
}
else if (feedType == 'UNSEEN'){
additional_parameters = '';
}
else if (feedType == 'BOOKMARKS'){
additional_parameters = '&bookmarked=True'+this.userID;
theCategoriesWanted = 'ALL';
}
return this.djangoAuth.createHeaders(true).then((headers) => {
var options = new RequestOptions({headers: headers, withCredentials: this.djangoAuth.use_session});
return new Promise(resolve => {
this.http.get(API_ENDPOINT + 'items/?categories=' + theCategoriesWanted + '&num=' + numberItemsToGet + '&user=' + this.userID + '&format=json' + additional_parameters, options)
.map(res => res.json())
.subscribe(
(data: any) => {
this.data = data;
resolve(this.data);
},
(err: any) => {
resolve("api/items returned error: " + err);
},
() => {
//alert('Complete');
}
);
});
});
}
This code used to work before I updated to ionic 2 RC0.
答案 0 :(得分:0)
尝试更新IDE以使用Typescript 2.0.3和ECMAScript6
这对我有用。