我有一个奇怪的行为试图更新 我使用reader.onload
时的视图var openIdParams = {
IdentityPoolId: process.env.TenantIdentityPoolId,
Logins: {
'tenant.login': result[0].email
},
IdentityId: null,
TokenDuration: 900 //900 = 15 minutes
};
return new Promise((resolve, reject) => {
console.log("here");
cognitoidentity.getOpenIdTokenForDeveloperIdentity(openIdParams, (err,
dataP) => {
console.log("here 1");
if (err) reject(err, err.stack); // an error occurred
else resolve(dataP); // successful response
});
为什么地球上的视图不会更新?
在角度6中,代码很好用。
我希望避免使用https://angular.io/api/core/ChangeDetectorRef
使用可观察的
imagePreview: ArrayBuffer | string = 'init';
onImageUpload(event: Event) {
const file = (<HTMLInputElement>event.target).files[0];
const reader = new FileReader();
reader.onload = () => {
this.imagePreview = reader.result as ArrayBuffer;
// this doesnt work
};
// this work
this.imagePreview = 'upload';
reader.readAsDataURL(file);
this.upload.emit(event);
}