Angular 如何找到包含错误的文件?
hy.我刚刚将我的应用程序更新为angular 4.4.3和最新的angular材质。在经历了大量错误之后,现在我只得到了一个,但看起来有点混乱,因为很难理解错误文件的名称。 我得到一个错误:Angular 如何找到包含错误的文件?,angular,visual-studio-2015,angular-material2,typescript2.0,Angular,Visual Studio 2015,Angular Material2,Typescript2.0,hy.我刚刚将我的应用程序更新为angular 4.4.3和最新的angular材质。在经历了大量错误之后,现在我只得到了一个,但看起来有点混乱,因为很难理解错误文件的名称。 我得到一个错误: (SystemJS) Invalid provider - only instances of Provider and Type are allowed, got: [object Object] Error: Invalid provider - only instances of Provi
(SystemJS) Invalid provider - only instances of Provider and Type are allowed, got: [object Object]
Error: Invalid provider - only instances of Provider and Type are allowed, got: [object Object]
at invalidProviderError (http://localhost:8080/node_modules/@angular/core/bundles/core.umd.js:1317:12)
at eval (http://localhost:8080/node_modules/@angular/core/bundles/core.umd.js:2118:19)
at Array.forEach (<anonymous>)
at _normalizeProviders (http://localhost:8080/node_modules/@angular/core/bundles/core.umd.js:2107:15)
at eval (http://localhost:8080/node_modules/@angular/core/bundles/core.umd.js:2115:13)
at Array.forEach (<anonymous>)
at _normalizeProviders (http://localhost:8080/node_modules/@angular/core/bundles/core.umd.js:2107:15)
at resolveReflectiveProviders (http://localhost:8080/node_modules/@angular/core/bundles/core.umd.js:2058:39)
at Function.ReflectiveInjector.resolve (http://localhost:8080/node_modules/@angular/core/bundles/core.umd.js:2287:16)
at Function.ReflectiveInjector.resolveAndCreate (http://localhost:8080/node_modules/@angular/core/bundles/core.umd.js:2319:79)
Evaluating http://localhost:8080/main.js
Error loading http://localhost:8080/main.js
at invalidProviderError (http://localhost:8080/node_modules/@angular/core/bundles/core.umd.js:1317:12)
at eval (http://localhost:8080/node_modules/@angular/core/bundles/core.umd.js:2118:19)
at Array.forEach (<anonymous>)
at _normalizeProviders (http://localhost:8080/node_modules/@angular/core/bundles/core.umd.js:2107:15)
at eval (http://localhost:8080/node_modules/@angular/core/bundles/core.umd.js:2115:13)
at Array.forEach (<anonymous>)
at _normalizeProviders (http://localhost:8080/node_modules/@angular/core/bundles/core.umd.js:2107:15)
at resolveReflectiveProviders (http://localhost:8080/node_modules/@angular/core/bundles/core.umd.js:2058:39)
at Function.ReflectiveInjector.resolve (http://localhost:8080/node_modules/@angular/core/bundles/core.umd.js:2287:16)
at Function.ReflectiveInjector.resolveAndCreate (http://localhost:8080/node_modules/@angular/core/bundles/core.umd.js:2319:79)
Evaluating http://localhost:8080/main.js
Error loading http://localhost:8080/main.js
AppModule
中只有一个位置可能与提供者相关
:
//changes languages that are set locally
import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
@NgModule({
imports: [...,
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: HttpLoaderFactory,
deps: [Http]
}
})
此外,在路由的其他零部件文件中还有其他位置:
//used for listing json as treeview
import {
TreeviewI18n,
TreeviewItem, TreeviewConfig,
TreeviewHelper,
TreeviewComponent,
TreeviewEventParser, OrderDownlineTreeviewEventParser,
DownlineTreeviewItem
} from 'ngx-treeview';
@Component({
selector: '...',
templateUrl: '...',
providers: [HttpService,
{ provide: TreeviewEventParser, useClass: OrderDownlineTreeviewEventParser }
]
})
检查模块中的提供程序-可能传递的是对象而不是提供程序类 您遇到了无效提供程序的问题,此提供程序的对象必须是[object]。但是添加您的代码,因为这不是答案,这只是调试错误所说的。问题在于
AppModule
内部,您正在将错误的“东西”添加到AppModules提供程序
数组中。发布你的AppModule
@PierreDuc你能看看我更新的帖子吗?@AmoT请发布你的AppModule
全文。
//used for listing json as treeview
import {
TreeviewI18n,
TreeviewItem, TreeviewConfig,
TreeviewHelper,
TreeviewComponent,
TreeviewEventParser, OrderDownlineTreeviewEventParser,
DownlineTreeviewItem
} from 'ngx-treeview';
@Component({
selector: '...',
templateUrl: '...',
providers: [HttpService,
{ provide: TreeviewEventParser, useClass: OrderDownlineTreeviewEventParser }
]
})