私は角度4を使用していました。突然、私はサービスをしてサービスにHttp
を注入したときにエラーと警告を表示しました。警告:角度依存性の名前が繰り返されているモジュール
./~/@angular/Http/@angular/http.es5.js
There are multiple modules with names that only differ in casing.
This can lead to unexpected behavior when compiling on a filesystem
with other case-semantic.
Use equal casing. Compare these module identifiers:
* /Users/centroagdigital/Documents/...ui/node_modules/@angular/Http/@angular/http.es5.js
Used by 1 module(s), i. e.
.../components/company-select/company-select.service.ts
実際のエラーは、次のとおりです。ここで
Error: No provider for Http!
at injectionError (core.es5.js:1169)
at noProviderError (core.es5.js:1207)
私はこのモジュールを使用するクラスです。
company-select.module.ts
:
import { NgModule } from '@angular/core';
import { CompanySelect } from './company-select.component';
import { HttpModule } from '@angular/http';
// service
import { CompanySelectService } from './company-select.service'
@NgModule({
providers: [
CompanySelectService
],
declarations: [
CompanySelect
],
imports: [
HttpModule
],
exports: [
CompanySelect
]
})
export class CompanySelectModule { }
company-select.service.ts
:
import { Injectable } from '@angular/core';
import { Http } from '@angular/Http';
// models
import { Company } from './models/company.interface'
@Injectable()
export class CompanySelectService
{
constructor(private http : Http){}
getCompanies() // : Company[] not implemented yet
{
return "";
}
}
どのように '角度/ HTTP @' から 'インポート{のHttp}の変更については、' 'インポート{のHttp}には、 from '@ angular/http'; 'あなたのサービスで? –