私はS3ストレージに画像をアップロードするためにMeteor-Angular2とslingshotパッケージを使用しています。関数から戻り、バインドされた文字列に代入すると、ビューは更新されません。 (setTimout機能が作動し、表示を更新するが、アップローダの関数ではない)コールバック関数の後にAngular2ビューが更新されない
export class AdminComponent {
public urlVariable: string = "ynet.co.il";
constructor() {
this.uploader = new Slingshot.Upload("myFileUploads");
setTimeout(() => {
this.urlVariable = "View is updated";
}, 10000);
}
onFileDrop(file: File): void {
console.log('Got file2');
this.uploader.send(file, function (error, downloadUrl) {
if (error) {
// Log service detailed response
}
else {
this.urlVariable = "View not updated";
}
});
}
}
ルータの別のルートに移動したり、ページを更新したりしない限り、ビューは更新されません。 – roish
'onFileDrop'はどこから呼び出されていますか? –
ありがとう! あなたの答えとthis._ngZone.run(()=> {this.urlVariable = "ビューは更新されません";});それは今働いており、すぐに更新しています! :-) – roish