如何使用角度材料2 FAB按钮打开浏览输入对话框?这可以通过这种方式在
HTML中完成.
- <button type="button">
- <label for="file-input">click</label>
- </button>
- <input type="file" id="file-input" style="display:none">
我尝试使用与材料2相同的方法,但它不起作用.
- <button md-mini-fab type="button">
- <label for="fileToUpload">
- <md-icon>add</md-icon>
- </label>
- </button>
- <input id="fileToUpload" type="file" style="display:none;">
还有其他方法可行吗?谢谢.
您只需触发文件输入的单击即可.
- <button md-mini-fab type="button" onclick="document.getElementById('fileToUpload').click()">
- <label for="fileToUpload"><md-icon>add</md-icon></label>
- </button>
- <input id="fileToUpload" type="file" style="display:none;">