所以我在一個包含它自己的表單元素和按鈕的指令中工作,但是所有的控件都必須被跨越。該特定視圖的模型包含一個用於總容量的屬性,以及一個屬於隔離專區(獨立實體)的屬性。每個隔間都有自己的容量。如果/當總容量不等於所有隔間的總容量時,我已經有一個功能在視圖上顯示錯誤。這裏的問題是,因爲我所有的控件都被跨越了(我不應該修改父指令),所以我不知道如何/如何使用相同的函數將窗體標記爲無效以禁用保存按鈕。我想知道是否有解決方案(希望不涉及自定義指令或服務的解決方案),如果表達式返回true,則可以將父表單設置爲無效。通過子控件進行自定義驗證
**更新**
對不起球員,我想我解釋它向後第一次。所以這將是一個很好的代表HTML中發生了什麼。 (我也沒有計算器使用這種以前好多如此忍受我)
編輯頁面指令:
<div>
<form name="editForm">
<ng-transclude>
</ng-transclude>
<a class="btn btn-success">Save</a>
<a class="btn btn-danger">Cancel</a>
</form>
</div>
查看此特定編輯:
<edit-page>
<uib-tabset>
<uib-tab>
<!--Total Capacity input-->
<input type="text" numeric="{min:1, format:'#,###.#'}" ng-model-options="{updateOn: 'blur'}" class="form-control" id="tcCapacity" name="tcCapacity" data-ng-required="true" ng-model="vm.dataContext.entity.TotalCapacity" />
<!--End Total Capacity-->
</uib-tab>
<uib-tab>
<table>
<tr><thead><th>...</th><th>Capacity</th><th>(Buttons for compartment add/remove)</th></thead></tr>
<tr ng-repeat="compartment in vm.dataContext.entity.TrailerConfigCompartments">
<td width="200">{{compartment.Sequence}}</td>
<!--Important input under this-->
<td><input type="text" numeric="{min:0, format:'#,###.#'}" class="form-control" ng-model="compartment.Capacity" data-ng-required="true" /></td>
<!--Important input above-->
<td align="right" style="padding-right:30px;">
<a class="btn" style="padding: .7em; color: black;" ng-click="vm.addCompartment(compartment.Sequence + 1)">
<span uib-tooltip="New compartment at sequence {{compartment.Sequence + 1}}" class="btn-edit" style='margin-left:5px'><span class="glyphicon glyphicon-plus" style="margin-top:3px"></span></span>
</a>
<a class="btn" style="padding: .7em; color: black;" ng-click="vm.removeCompartment(compartment)">
<span uib-tooltip="Remove compartment" class="btn-edit" style='margin-left:5px'><span class="glyphicon glyphicon-minus" style="margin-top:3px"></span></span>
</a>
</td>
</tr>
</table>
</uib-tab>
</uib-tabset>
</edit-page>
嘿謝謝你這麼快就回復,看起來像我向後解釋。我更新了這個問題,儘管給你一個關於我正在工作的好主意 –