重复的名字我一直在使用的角度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从'@ angular/http';'在你的服务中? –