我正在将我的应用程序从angular2 RC5与angular-webpack脚手架迁移到角度2 2.0.0,角度为cli beta 14.
我正在与这些错误作斗争:
未捕获错误:无法解析PublicInfoDao的所有参数:(?,?).CompileMetadataResolver.getDependenciesMetadata @ metadata_resolver.js:508CompileMetadataResolver.getTypeMetadata @ metadata_resolver.js:405(匿名函数)@ metadata_resolver.js:552CompileMetadataResolver.getProvidersMetadata @ metadata_resolver. JS:532CompileMetadataResolver.getNgModuleMetadata @ metadata_resolver.js:285RuntimeCompiler._compileComponents @ runtime_compiler.js:126RuntimeCompiler._compileModuleAndComponents @ runtime_compiler.js:64RuntimeCompiler.compileModuleAsync @ runtime_compiler.js:55PlatformRef _._ bootstrapModuleWithZone @ application_ref.js:303PlatformRef_.bootstrapModule @ application_ref.js: 285(匿名函数)@main.ts:13__webpack_require__ @ bootstrap db3609d ...:52(匿名函数)@.*$:7__webpack_require__ @ bootstrap db3609d ...:52webpackJsonpCallback @ bootstrap db3609d ...:23(匿名函数)@main.bundle.js: 1
和
metadata_resolver.js:278Uncaught错误:模块'AppModule'(匿名函数)@ metadata_resolver.js声明的意外值'AppComponent':278CompileMetadataResolver.getNgModuleMetadata @ metadata_resolver.js:265RuntimeCompiler._compileComponents @ runtime_compiler.js:126RuntimeCompiler._compileModuleAndComponents @ runtime_compiler. js:64RuntimeCompiler.compileModuleAsync @ runtime_compiler.js:55PlatformRef _._ bootstrapModuleWithZone @ application_ref.js:303PlatformRef_.bootstrapModule @ application_ref.js:285(匿名函数)@main.ts:13__webpack_require__ @ bootstrap db3609d ...:52(匿名函数)@.*$:7__webpack_require__ @ bootstrap db3609d ...:52webpackJsonpCallback @ bootstrap db3609d ...:23(匿名函数)@main.bundle.js:1 1:https: //github.com/preboot/angular2-webpack
如果我删除应用程序的几个组件,这是一个奇怪的行为原因.但是,如果我添加一个简单的组件,如:
@Component({
selector: 'tl-result-item',
templateUrl: "./resultitem.component.html",
styleUrls: ["./resultitem.component.scss"]
})
export class ResultItemComponent {
@Input()
result:Result;
constructor(){}
}
Run Code Online (Sandbox Code Playgroud)
抛出第二个错误.如果我评论@Input()该应用程序的工作.有一些服务,如果我取消注释应用程序抛出相同的错误,如果我评论一些行错误消失.
我对这些错误感到疯狂.我认为它应该是一个外部问题.
任何的想法?
更新:
第一个错误可能与https://github.com/AngularClass/angular2-webpack-starter#frequently-asked-questions有关(第二个问题)我有几个问题需要迁移到angular 2.0.0 final.
UPDATE2:
@NgModule({
providers: [
MetaService,
Title,
HttpInterceptor,
{provide: ConnectionBackend, useClass: XHRBackend},
{provide: Http, useExisting: HttpInterceptor},
{provide: Configuration, useClass: ConfigurationDevelopment}
],
imports: [
BrowserModule,
HttpModule,
FormsModule,
ReactiveFormsModule,
// APP_ROUTER_PROVIDERS
],
declarations: [
AppComponent,
ResultItemComponent,
TimestampToMomentPipe,
TimestampToTimePipe
],
bootstrap: [AppComponent]
})
export class AppModule {
}
Run Code Online (Sandbox Code Playgroud)
Update3: 另一个在angular cli中失败的代码示例.
此代码正常工作:
this.publicService.all().subcribe(response => {
console.log(response);
});
Run Code Online (Sandbox Code Playgroud)
此代码失败:
this.publicService.all().subcribe(response => {
deserialize(response)
});
Run Code Online (Sandbox Code Playgroud)
以上解释的例外情况:
未捕获错误:无法解析PublicInfoDao的所有参数:(?,?).
¿¿?
环境.ts
// Angular 2
// rc2 workaround
import { enableDebugTools, disableDebugTools } from '@angular/platform-browser';
import { enableProdMode, ApplicationRef } from '@angular/core';
// Environment Providers
let PROVIDERS: any[] = [
// common env directives
];
// Angular debug tools in the dev console
// https://github.com/angular/angular/blob/86405345b781a9dc2438c0fbe3e9409245647019/TOOLS_JS.md
let _decorateModuleRef = function identity<T>(value: T): T { return value; };
if ('production' === ENV) {
// Production
disableDebugTools();
enableProdMode();
PROVIDERS = [
...PROVIDERS,
// custom providers in production
];
} else {
_decorateModuleRef = (modRef: any) => {
const appRef = modRef.injector.get(ApplicationRef);
const cmpRef = appRef.components[0];
let _ng = (<any>window).ng;
enableDebugTools(cmpRef);
(<any>window).ng.probe = _ng.probe;
(<any>window).ng.coreTokens = _ng.coreTokens;
return modRef;
};
// Development
PROVIDERS = [
...PROVIDERS,
// custom providers in development
];
}
export const decorateModuleRef = _decorateModuleRef;
export const ENV_PROVIDERS = [
...PROVIDERS
];
Run Code Online (Sandbox Code Playgroud)
应用程序模块.ts
@NgModule({
providers: [
// expose our Services and Providers into Angular"s dependency injection
ENV_PROVIDERS
],
imports: [
BrowserModule,
HttpModule,
FormsModule,
ReactiveFormsModule,
// APP_ROUTER_PROVIDERS
],
declarations: [
AppComponent,
ResultItemComponent,
TimestampToMomentPipe,
TimestampToTimePipe
],
bootstrap: [AppComponent]
})
export class AppModule {
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1034 次 |
| 最近记录: |