2016-05-02 10 views
0

私はAngular2ベータ15で動作していましたが、それをベータ17にアップデートしました。error2のベータ版を更新しています - ベータ17

EXCEPTION: Can only add to a TokenMap! Token: ElementRef angular2.dev.js:25654 
EXCEPTION: Can only add to a TokenMap! Token: ElementRef angular2.dev.js:25644:9 

Object { message: "Can only add to a TokenMap! Token: …", stack: "[email protected]://localhost:3000…" } boot.js:25:107 

EXCEPTION: Error: Uncaught (in promise): Can only add to a TokenMap! Token: ElementRef angular2.dev.js:25654 
EXCEPTION: Error: Uncaught (in promise): Can only add to a TokenMap! Token: ElementRef angular2.dev.js:25644:9 

STACKTRACE: angular2.dev.js:25644:9 

[email protected]://localhost:3000/node_modules/angular2/bundles/angular2-polyfills.js:564:32 
scheduleResolveOrReject/<@http://localhost:3000/node_modules/angular2/bundles/angular2-polyfills.js:600:18 
Zone</ZoneDelegate</[email protected]://localhost:3000/node_modules/angular2/bundles/angular2-polyfills.js:382:24 
NgZoneImpl/this.inner<[email protected]://localhost:3000/node_modules/angular2/bundles/angular2.dev.js:2181:22 
Zone</ZoneDelegate</[email protected]://localhost:3000/node_modules/angular2/bundles/angular2-polyfills.js:381:24 
Zone</Zone</[email protected]://localhost:3000/node_modules/angular2/bundles/angular2-polyfills.js:282:29 
[email protected]://localhost:3000/node_modules/angular2/bundles/angular2-polyfills.js:500:26 
ZoneTask/[email protected]://localhost:3000/node_modules/angular2/bundles/angular2-polyfills.js:452:22 
angular2.dev.js:25644:9 

Unhandled Promise rejection: Can only add to a TokenMap! Token: ElementRef ; Zone: angular ; Task: Promise.then ; Value: Object { message: "Can only add to a TokenMap! Token: …", stack: "[email protected]://localhost:3000…" } angular2-polyfills.js:487:14 

Error: Uncaught (in promise): Can only add to a TokenMap! Token: ElementRef 
Stack trace: 
[email protected]://localhost:3000/node_modules/angular2/bundles/angular2-polyfills.js:564:32 
scheduleResolveOrReject/<@http://localhost:3000/node_modules/angular2/bundles/angular2-polyfills.js:600:18 
Zone</ZoneDelegate</[email protected]://localhost:3000/node_modules/angular2/bundles/angular2-polyfills.js:382:24 
NgZoneImpl/this.inner<[email protected]://localhost:3000/node_modules/angular2/bundles/angular2.dev.js:2181:22 
Zone</ZoneDelegate</[email protected]://localhost:3000/node_modules/angular2/bundles/angular2-polyfills.js:381:24 
Zone</Zone</[email protected]://localhost:3000/node_modules/angular2/bundles/angular2-polyfills.js:282:29 
[email protected]://localhost:3000/node_modules/angular2/bundles/angular2-polyfills.js:500:26 
ZoneTask/[email protected]://localhost:3000/node_modules/angular2/bundles/angular2-polyfills.js:452:22 
angular2-polyfills.js:489:10 
+1

に変更されている 'ElementRef'に関する同様のエラーが発生しました。 'ViewContainerRef'のためにそれを切り替える必要がありました。コードでは、 'ElementRef'の出現をチェックする必要があります。それらで処理するコンストラクタ/関数は、そのパラメータに関して変更されている可能性があります。 – lexith

答えて

0

あなたはDynamicComponentLoader使用法を使用している場合

export class DclWrapper { 
    // get `ViewContainerRef` using `@ViewChild()` or by injecting it 
    // if the component itself should be the target 
    @ViewChild('target', {read: ViewContainerRef}) target; 
    @Input() type; 
    cmpRef:ComponentRef; 
    private isViewInitialized:boolean = false; 

    constructor(private dcl:DynamicComponentLoader) {} 

    updateComponent() { 
    // should be executed every time `type` changes but not before `ngAfterViewInit()` was called 
    // to have `target` initialized 
    if(!this.isViewInitialized) { 
     return; 
    } 
    if(this.cmpRef) { 
     throw 'currently changing type after the component was added is not supported' 
    } 
    // LoadIntoLocation was renamed and now takes a `ViewContainerRef` 
    // instead of `ElementRef` and `target` 
    this.dcl.loadNextToLocation(this.type, this.target).then((cmpRef) => { 
     this.cmpRef = cmpRef; 
    }); 
    } 

    ngOnChanges() { 
    this.updateComponent(); 
    } 

    ngAfterViewInit() { 
    this.isViewInitialized = true; 
    this.updateComponent(); 
    } 
} 
+0

私のケースでは、DynamicComponentLoaderを使用していません – Sergio

+0

新しいAngularバージョンとまだ互換性のないサードパーティコンポーネントを使用していますか? –

+0

唯一のサードパーティはprimengですが、最新のbeta17と互換性があります – Sergio

関連する問題