[英]Cannot export service angular library
Hi i am trying to export a service from my library but i am always getting an error.嗨,我正在尝试从我的图书馆导出服务,但我总是遇到错误。 this is my module where i import the service:
这是我导入服务的模块:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule, APP_INITIALIZER } from '@angular/core';
import { AppConfigService } from 'ecarelib/lib/services/app-config.service';
@NgModule({
declarations: [
AppComponent,
],
imports: [
BrowserModule,
],
bootstrap: [AppComponent],
providers: [AppConfigService]
})
export class AppModule { }
Public-api:公共 API:
export * from './lib/services/app-config.service';
ERROR in ./src/app/app.module.ts Module not found: Error: Can't resolve 'ecarelib/lib/services/app-config.service' in 'C:\\Users\\ArneVandenEynden\\vitalsigns\\Ecare.VitalSigns.Client\\src\\app' ./src/app/app.module.ts 中的错误未找到模块:错误:无法解析“C:\\Users\\ArneVandenEynden\\vitalsigns\\Ecare.VitalSigns”中的“ecarelib/lib/services/app-config.service” .Client\\src\\app'
I think this is because the import path for ' AppConfigService ' provided in AppModule is incorrect.我认为这是因为AppModule 中提供的“ AppConfigService ”的导入路径不正确。 You should give the relative path there.
你应该在那里给出相对路径。
For example:例如:
If the AppConfigService 's path is src>ecarelib>lib>services>app-config.service and AppModule 's path is src>app>app.module , then the import path that we should provide is the relative path as shown below:如果AppConfigService的路径是src>ecarelib>lib>services>app-config.service , AppModule的路径是src>app>app.module ,那么我们应该提供的导入路径是如下所示的相对路径:
import { AppConfigService } from '../ecarelib/lib/services/app-config.service';
Instead of :代替 :
import { AppConfigService } from 'ecarelib/lib/services/app-config.service';
Hope this would resolve the issue.希望这能解决问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.