Last active
September 23, 2017 04:18
-
-
Save mmccall10/572cb7d99beec316ca322f7faf4ed4e4 to your computer and use it in GitHub Desktop.
Basic form with file input (article embed)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>Angular File Input</h1> | |
<!-- IMG preview --> | |
<img [src]="fileDataUri"> | |
<p *ngIf="errorMsg" style="color:red">{{errorMsg}}</p> | |
<!-- Form with submit method and template variable (#fileInput) --> | |
<form (submit)="uploadFile($event)"> | |
<input | |
type="file" | |
(change)="previewFile()" | |
#fileInput | |
> | |
<button | |
type="submit" | |
[disabled]="fileDataUri.length === 0" | |
>Upload</button> | |
</form> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment