簡體   English   中英

在Angular JS中禁用ng

[英]ng-disabled in Angular JS

我有一個模態彈出式窗口,其中包含一些必填字段。

   <form name="myReferenceDataForm" role="form" ng-submit="AddNewGroupMembershipReferenceRecord()" style="margin: 10px">
        <div class="form-group row">
            <div style="padding-bottom:5px; padding-top:5px; ">
                    <label for="GroupCode" class="col-sm-4 form-control-label">
                            Group Code <span class="requiredRed">*</span>
                    </label>
                    <div class="col-sm-8">
                        <input ng-model="referenceAddRecord.groupCode" class="form-control" id="GroupCode" type="text">
                    </div>
            </div>
        </div>
        <div class="form-group row">
            <div style="padding-bottom:5px; padding-top:5px; ">
                <label for="GroupName" class="col-sm-4 form-control-label">
                    Group Name <span class="requiredRed">*</span>
                </label>
                <div class="col-sm-8">
                    <input ng-model="referenceAddRecord.groupName" id="GroupName" class="form-control" type="text">
                </div>
            </div>
        </div>
        <div class="form-group row">
            <label for="GroupType" class="col-sm-4 form-control-label">Group Type </label>
            <div class="col-sm-8">
                <select name="selGroupType" id="selGroupType" class="form-control" ng-change="referenceAddRecord.populateGroupTypeDetails(selGroupType)" ng-options="groupType.value for groupType in referenceAddRecord.groupTypes track by groupType.id" ng-model="referenceAddRecord.groupType"></select>
            </div>
        </div>

只有上面3個字段groupName , groupCode是必需的。

如果它們存在或未填充,我想禁用頁面中的“提交”按鈕。

所以我做了 ...

        <input type="submit" class="btn btn-default pull-right" style="width:100px;" value="Submit" ng-disabled="!(referenceAddRecord.groupCode || referenceAddRecord.groupName)|| addReferenceDataGroupNameExists() || addReferenceDataGroupCodeExists()" />

但這是行不通的。 甚至只有檢查whether the fields are filled失敗。 每當我僅輸入一個字段時,它就會啟用。

        <input type="submit" class="btn btn-default pull-right" style="width:100px;" value="Submit" ng-disabled="!(referenceAddRecord.groupCode || referenceAddRecord.groupName)" />

我在這里做錯了什么?

看看這個矮人

<input type="submit" id="submit" ng-disabled="!(referenceAddRecord.groupName && referenceAddRecord.groupCode)" value="Submit" />

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM