私はHttpをインポートするサービスを持っています。私のアプリでそれを使用すると、エラーがスローされます。 "g injectionErrorでHttp!Errorのプロバイダがありません"です。私はアプリをlazyloadingしています。また、プロバイダは "ionic g provider ...
"角4とイオン3 HTTPのプロバイダなし
苦情-service.ts CLIによって
import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import 'rxjs/add/operator/map';
@Injectable()
export class ComplaintService {
private complaints: {subject: string, description: string}[] = [];
constructor(public http: Http) {
this.http = http;
this.complaints = null;
console.log('Hello ComplaintService Provider');
}
addComplaints(complaint: {subject: string, description: string}) {
this.complaints.push(complaint);
}
getComplaints() {
return this.complaints.slice();
}
}
苦情-form.ts
import { Component } from '@angular/core';
import {Validators, FormBuilder, FormGroup } from '@angular/forms';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import {ComplaintService} from '../../providers/complaint-service';
@IonicPage()
@Component({
selector: 'page-complaint-form',
templateUrl: 'complaint-form.html',
providers: [ComplaintService]
})
export class ComplaintForm {
}
任意の提案を生成したのか?
あなたはあなたのモジュール – devqon
@devqonで 'providers'に' Http'を登録する必要があります - 私たちは遅延ロードしながら、それを必要としませんまた? – abhiklpm
IonicのネイティブプラグインからのAngularから** HTTP **への** Http' **の違いに注意してください。後者のために 'no provider error'を得る場合は' ion-native'_から 'app.module.ts'にインポートできる' HTTP' - _を含めてください。 –