|
@@ -13,6 +13,7 @@ export class PageAddComponent {
|
|
|
tag: '',
|
|
|
desc: ''
|
|
|
};
|
|
|
+ selectedImage: string | ArrayBuffer | null = null;
|
|
|
|
|
|
constructor(
|
|
|
private router: Router
|
|
@@ -25,6 +26,7 @@ export class PageAddComponent {
|
|
|
newContact.set('name', this.userAdd.name);
|
|
|
newContact.set('tag', this.userAdd.tag);
|
|
|
newContact.set('desc', this.userAdd.desc);
|
|
|
+ newContact.set('img', this.userAdd.img);
|
|
|
// 设置其他联系人信息...
|
|
|
|
|
|
try {
|
|
@@ -35,4 +37,16 @@ export class PageAddComponent {
|
|
|
console.error('Error while saving new contact', error);
|
|
|
}
|
|
|
}
|
|
|
-}
|
|
|
+
|
|
|
+ onFileSelected(event: Event) {
|
|
|
+ const inputElement = event.target as HTMLInputElement;
|
|
|
+ if (inputElement.files && inputElement.files[0]) {
|
|
|
+ const file = inputElement.files[0];
|
|
|
+ const reader = new FileReader();
|
|
|
+ reader.onload = () => {
|
|
|
+ this.selectedImage = reader.result;
|
|
|
+ };
|
|
|
+ reader.readAsDataURL(file);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|