How can I use angular material 2 FAB buttons to open a browse input dialog? This can be done in HTML by this way.
<button type="button"> <label for="file-input">click</label> </button> <input type="file" id="file-input" style="display:none">
I tried following the same approach with material 2, but it doesn't work.
<button md-mini-fab type="button"> <label for="fileToUpload"> <md-icon>add</md-icon> </label> </button> <input id="fileToUpload" type="file" style="display:none;">
Are there any other ways that will work? Thank you.
Matinput is an Angular directive that primarily allows input and text area elements to work with a form field. With this, you can display placeholders perfectly, add custom error messages, a clear button, specify the maximum length of the text or add prefixes and suffixes for a seamless user experience.
MatFormFieldControl. An interface which allows a control to work inside of a MatFormField .
Here is a simple solution:
<button (click)="fileInput.click()"> <md-icon>library_add</md-icon> <span>Select</span> <input #fileInput type="file" (change)="onFileInput($event)" style="display:none;" /> </button>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With