2017-08-10 7 views
0

私は角度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 ""; 
    } 
} 
+0

どのように '角度/ HTTP @' から 'インポート{のHttp}の変更については、' 'インポート{のHttp}には、 from '@ angular/http'; 'あなたのサービスで? –

答えて

0

あなたCompanySelectModuleで、あなたは小文字の 'H'、あなたのCompanySelectServiceに、あなたは資本 'H' とimport { HttpModule } from '@angular/Http';を使用してimport { HttpModule } from '@angular/http'; を使用します!

@Harryニンが示唆したように、小文字の 'h' を使用するようにCompanySelectServiceでインポートを変更しようと

+0

Omgありがとう! 2時間とエラーを見つけることができません – Fransebas

関連する問題