我在IBM MobileFirst Platform 8.0( mfpdev verion 8.0.0-2016070716 )支持的Ionic 2( v 2.0.0-beta.32 )应用程序中创建了一个提供程序Beta版。以下是代码:
import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
@Injectable()
export class EmployeeService {
data: any;
constructor() {
this.data = null;
}
load() {
console.log('--> called employee service');
if (this.data) {
// already loaded data
return Promise.resolve(this.data);
}
// don't have the data yet
return new Promise(resolve => {
let dataRequest = new WLResourceRequest("/adapters/messangerAdapter/getEmployeeRating",WLResourceRequest.GET);
/*dataRequest.send().then((response) => {
console.log('--> adapter response recieved', response.responseJSON.results);
this.data = response.responseJSON.results;
resolve(this.data);
});*/
});
}
}
当我编译代码时,我收到以下错误:
TypeScript error: E:/Worklight Mobile App/MFP 8.0 Eclipse and WS/workspace/MobileApp/TestProject/app/providers/employee-service/employee-service.ts(30,94): Error TS2304: Cannot find name 'WLResourceRequest'.
我已将mfp插件添加到离子项目中。为了使这项工作还有其他我需要做的事情吗?
答案 0 :(得分:6)
您可以尝试将其添加为文件的第一行吗? (在import
之前)
/// <reference path="../../../plugins/cordova-plugin-mfp/typings/worklight.d.ts" />