2016-04-06 14 views
2

タブを切り替えるだけのコンポーネントを使用しました。動的にロードされたコンポーネントの中に角度2の片方向データバインディングがリフレッシュされない

私は動的コンポーネントロードコンポーネント内にコンポーネントを移動したら、私はfalseから機能setTab(){ this.tabInfo = true }で設定したとき、私は私が{{ tabInfo }}で印刷テンプレートにfalseが残っています。

なぜデータが更新されないのですか?私は爽やかなゾーンを試して、それは動作しません。

機能が実行されていて、すべての値が正しく設定されています。コンソールを確認しました。しかし、変更はテンプレートには表示されません。私がコンストラクタで設定したものは固定されていますが、変更できません。

アイデア?

答えて

1

あなたがloadAsRoot()を使用している場合は、私がルートとしての負荷は問題である理由、それは「ID = someid」を参照し、loadIntoLocationがある今入手明示的にも

function onYourComponentDispose() { 
} 
let el = this.elementRef 
let reuseInjectorOrCreateNewOne = this.injector; 
this.componentLoader.loadAsRoot(YourComponent, this.elementRef, reuseInjectorOrCreateNewOne, onYourComponentDispose) 
.then((compRef: ComponentRef) => { 
    // manually include Inputs 
    compRef.instance['myInputValue'] = {res: 'randomDataFromParent'}; 
    // manually include Outputs 
    compRef.instance['myOutputValue'].subscribe(this.parentObserver) 
    // trigger change detection 
    cmpRef.location.internalElement.parentView.changeDetector.ref.detectChanges() 
    // always return in a promise 
    return compRef 
}); 

見られるようなhttps://github.com/angular/angular/issues/6370#issuecomment-193896657

+0

を変更検出を起動する必要があります#someidを使用して、それはまったく別の参照であり、それは壊れます。 OK。将来のデフォルトとしてloadIntoLocation;)。 Guntherありがとうございました。数分で回答を受け入れます... – Teddy

関連する問題