我一直在跟踪文档这里,并使用ng-cli。
我创建了以下配置文件(app-config.ts):
import { OpaqueToken } from '@angular/core';
export interface AppConfig {
supportTelephoneNumber: string;
}
export let APP_CONFIG_t = new OpaqueToken('app.config');
export const APP_CONFIG: AppConfig = {
supportTelephoneNumber: '1111 111 1111'
};在我的app.module.ts文件中有:
...
@NgModule({
declarations: [
UkCurrencyPipe,
AppComponent,
HomeComponent
],
imports: [
BrowserModule,
FormsModule,
HttpModule,
RouterModule.forRoot(ROUTES, { useHash: true }),
MaterialModule.forRoot()
],
providers: [
{ provide: APP_CONFIG_t, useValue: APP_CONFIG },
...我在我的app.component.ts文件中使用以下配置:
import { Component, Inject } from '@angular/core';
import { APP_CONFIG_t, AppConfig } from './app-config';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.less']
})
export class AppComponent {
constructor(@Inject(APP_CONFIG_t) public config: AppConfig) {
callSupport(): void {
window.location.href = 'tel:+' + this.config.supportTelephoneNumber;
}
}当我使用ng服务提供应用程序时,一切似乎都正常,但我确实在运行ng服务器的控制台中看到了这些警告。
在./src/app/app.component.ts中发出警告 40:166导出'AppConfig‘在'./app-config’中没有找到。 在./src/app/app.component.ts中发出警告 40:195出口'AppConfig‘在'./app-config’中没有找到。
有没有人知道这些警告是甚麽意思,我是否应该担心呢?
我的版本
发布于 2016-10-06 08:18:17
根据评论发布的https://github.com/angular/angular-cli/issues/2034
有同样的问题。(尽管有警告,但工作正常)您是否从文件中导出了多个接口/class/const?在我从自己的专用文件导出每个接口之后,问题就停止了。 这意味着如果我有一个具有多个导出的文件-我在构建中得到了警告(导出'MyInterface1‘在’./ file‘中找不到)
file.ts
export interface MyInterface1 {}
export interface MyInterface2 {}重构后-没有警告
file1.ts
export interface MyInterface1 {}
file2.ts
export interface MyInterface2 {}https://stackoverflow.com/questions/39857565
复制相似问题