0
我有一個窗體,它包括一個用於上傳照片的輸入文件。我想要的是禁用按鈕,直到輸入文件沒有價值。我也有其他驗證,使按鈕被禁用。ng禁用的按鈕,直到輸入文件被更改
我的HTML文件是這樣的
<form name="form" novalidate ng-submit="submitForm();">
<input class="btn btn-primary" type="file" accept="image/*" name="File" id="File" style=" margin-left:5px; width: 100%;">
<div class="form-group">
<label class="text-left control-label">Categories: </label>
<select class="col-xs-5 pull-right" ng-model="cat" name="cat" ng-required="true" required>
<option value="">---Please select---</option>
<option ng-repeat="item in Cat" value="{{item.categories_id}}">{{item.categories_name}}</option>
</select>
</div>
<br/>
<div class="form-group">
<label class="text-left control-label">Types: </label>
<select class="col-xs-5 pull-right" ng-model="type" name="type">
<option value="">---Please select---</option>
<option ng-repeat="item in Types" value="{{item.type_id}}">{{item.type_name}}</option>
</select>
</div>
<br/>
<div class="form-group">
<label class="text-leftcontrol-label">Gender: </label>
<select class="col-xs-5 pull-right" name="category" id="category" ng-model="gender">
<option value="">---Please select---</option>
<option value="0">Female</option>
<option value="1">Male</option>
<option value="2">Both</option>
</select>
</div>
<br/>
<div class="form-group">
<label class="text-left control-label">*Texture: </label>
<select class="col-xs-5 pull-right" ng-model="texture" name="texture" ng-required="true" required>
<option value="">---Please select---</option>
<option ng-repeat="item in Texture" value="{{item.textures_id}}">{{item.textures_name}}</option>
</select>
</div>
<br/>
</div>
<div class="col-xs-5">
<div class="form-group">
<label class="col-md-5 control-label">*Name: </label>
<div class="col-md-7">
<input type="text" class="pull-right input-group inline form-control" ng-model="name" name="name" id="Name" ng-required="true" required>
</div>
</div>
<br/><br/><br/>
</form>
和我的按鈕是這樣
<button name="submit" type="submit" id="submitsave" class="btn btn-primary" ng-disabled="form.texture.$invalid || form.cat.$invalid || form.type.$invalid " type="button" type="button" style="margin-right:1%; width:10%; height:10%">Finish</button>
http://stackoverflow.com/questions/29385861/angularjs-disable-submit-button-until-a-file-upload -path-selected – madhu
[AngularJs禁用提交按鈕,直到選定文件上傳路徑]的可能重複(http://stackoverflow.com/questions/29385861/angularjs-disable-submit-button-until-a-file-upload-path - 請選擇) –