submit() { if (!this.files.length) { return; } }
base64(file: File) { const fileReader = new FileReader(); this.renderer.listen(fileReader, 'load', event => this.src = event.target.result); // this.renderer.listen(fileReader, 'load', event => event => this.image.nativeElement.src = event.target.result); fileReader.readAsDataURL(file); } photo(event) { const fileList: FileList = event.target.files; if (!fileList.length) { return; } let file: File = null; const type = /^image\//; for (let i = 0; i < fileList.length; i++) { if (fileList[i].type.match(type)) { file = fileList[i]; break; } } if (file === null) { return; } this.file = file; // this.image(file); this.base64(file); } submit({ value }) { event.preventDefault(); if (this.file !== null) { value['file'] = this.file; } console.log('value', value); this.registration.step1 = Object.assign({ }, value); console.log('step', this.registration.step1); this.next(); }
Обсуждают сегодня