我正在尝试使用Cordova在Cordova + TypeScript + Angular中为我的rest api实现一个客户端类,我有类似的东西
myrestservice.ts :
export class MyRestService {
constructor(private http: HttpClient) {
}
doApiCall() {
// ...
}
}
并想在组件中使用 mycomponent.ts :
import { MyRestService } from './../../services/myrestservice';
// some othe includes here
import { Component, } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { NavController } from 'ionic-angular';
export class MyPage {
constructor(public navCtrl: NavController, public http: HttpClient) {
let aquabox = new MyRestService(http);
aquabox.doApiCall();
}
}
但是当我尝试运行该应用程序时,我看到了:
Error: Cannot find module "."
at webpackMissingModule (http://localhost:8100/build/vendor.js:117231:69)
at http://localhost:8100/build/vendor.js:117231:147
at Object.<anonymous> (http://localhost:8100/build/vendor.js:117240:3)
at __webpack_require__ (http://localhost:8100/build/vendor.js:55:30)
at Object.113 (http://localhost:8100/build/main.js:27:86)
at __webpack_require__ (http://localhost:8100/build/vendor.js:55:30)
at Object.222 (http://localhost:8100/build/main.js:285:71)
at __webpack_require__ (http://localhost:8100/build/vendor.js:55:30)
at Object.201 (http://localhost:8100/build/main.js:272:70)
at __webpack_require__ (http://localhost:8100/build/vendor.js:55:30)
您知道为什么会这样吗?我需要以某种方式“注册”我的MyRestService
类吗?