Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { Component, ChangeDetectionStrategy } from '@angular/core';
- import { FormsModule } from '@angular/forms';
- @Component({
- selector: 'my-app',
- templateUrl: './app.component.html',
- styleUrls: ['./app.component.css'],
- changeDetection: ChangeDetectionStrategy.OnPush
- })
- export class AppComponent {
- urls = new Array<string>();
- detectFiles(event) {
- this.urls = [];
- let files = event.target.files;
- if (files) {
- for (let file of files) {
- let reader = new FileReader();
- reader.onload = (e: any) => {
- this.urls.push(e.target.result);
- this.urls = [...this.urls]
- }
- reader.readAsDataURL(file);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement