未选择文件时禁用上载按钮 [英] Disable upload button when no file selected

查看:66
本文介绍了未选择文件时禁用上载按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<input type="file" ng-file-select ng-model="file" accept=".xls" name="inputFile" id="inputFile" required/>
        <div ng-show="uploadForm.inputFile.$dirty && uploadForm.inputFile.$invalid" 
        ng-messages="uploadForm.inputFile.$error" ng-messages-include="fileUpload-messages"></div></div>
        <div class="modal-footer"><button ng-class="{'button-style': uploadForm.$valid}" ng-disabled="uploadForm.$valid || !file" ng-click="upload(file);">Upload</button></div>

这是我没有选择文件时试图禁用上载按钮的那段代码.它无法正常工作.

This the piece of code i am trying with to disable upload button when no file is selected. It fails to work.

推荐答案

您应该将按钮的默认设置设为禁用.然后为所选内容创建一个侦听器.然后,一旦启用了侦听器并选择了某些内容,则应将button属性更改为"Enabled".

You should have the default for the button be disabled. Then create a listener for the selection. Then, once the listener is enabled and something is selected, you should change the button property to "Enabled".

这篇关于未选择文件时禁用上载按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆