Angular 2.0.0 Metadata_resolver奇怪的行为

前端之家收集整理的这篇文章主要介绍了Angular 2.0.0 Metadata_resolver奇怪的行为前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我将我的应用程序从角度2 RC5与 angular-webpack脚手架迁移到角度2 2.0.0与角cli beta 14.

我正在与这些错误进行战斗:

Uncaught Error: Can’t resolve all parameters for PublicInfoDao: (?,
?).CompileMetadataResolver.getDependenciesMetadata @
Metadata_resolver.js:508CompileMetadataResolver.getTypeMetadata @
Metadata_resolver.js:405(anonymous function) @
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(anonymous function) @
main.ts:13__webpack_require__ @ bootstrap db3609d…:52(anonymous
function) @ .*$:7__webpack_require__ @ bootstrap
db3609d…:52webpackJsonpCallback @ bootstrap db3609d…:23(anonymous
function) @ main.bundle.js:1

Metadata_resolver.js:278Uncaught Error: Unexpected value
‘AppComponent’ declared by the module ‘AppModule'(anonymous function)
@ Metadata_resolver.js: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(anonymous function) @
main.ts:13__webpack_require__ @ bootstrap db3609d…:52(anonymous
function) @ .*$:7__webpack_require__ @ bootstrap
db3609d…:52webpackJsonpCallback @ bootstrap db3609d…:23(anonymous
function) @ main.bundle.js:1 07001:
07002

如果我删除应用程序的几个组件,这是一个奇怪的行为.但是如果我添加一个简单的组件,如:

@Component({
  selector: 'tl-result-item',templateUrl: "./resultitem.component.html",styleUrls: ["./resultitem.component.scss"]
})
export class ResultItemComponent {

  @Input()
  result:Result;

  constructor(){}
}

抛出第二个错误.如果我评论@Input()的应用程序的工作.
有一些服务,如果我取消注释应用程序抛出相同的错误,如果我评论一些行错误disapears.

我对这些错误很疯狂.我认为这应该是一个外部问题.

任何想法?

更新:

第一个错误可能与https://github.com/AngularClass/angular2-webpack-starter#frequently-asked-questions有关(第二个问题)
我有几个问题迁移到角2.0.0决赛.

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 {
}

UPDATE3:
在角cli中失败的代码的另一个例子.

代码正常工作:

this.publicService.all().subcribe(response => {
      console.log(response);
});

代码失败:

this.publicService.all().subcribe(response => {
      deserialize(response)
});

上述异常:

Uncaught Error: Can’t resolve all parameters for PublicInfoDao: (?,
?).

¿¿?

environment.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
];

app.module.ts

@NgModule({
  providers: [
 // expose our Services and Providers into Angular"s dependency injection
        ENV_PROVIDERS
  ],bootstrap: [AppComponent]
})
export class AppModule {
}

猜你在找的Angularjs相关文章