ng-form
所以我依赖于使用指令下一步的链接。但我发现除了当前链接之外,接下来的步骤的另一个链接是enabled
.
所以我将其更改为使用 flag for ng-disabled
。这是我的代码:
索引.html
<div class="stepwizard-row setup-panel">
<div class="stepwizard-step">
<a ui-sref="step1" type="button" class="btn btn-primary btn-circle active-step-wizard">1</a>
</div>
<div class="stepwizard-step">
<a ng-disabled="step1Form.$invalid;" ui-sref="step2" type="button" class="btn btn-primary btn-circle active-step-wizard">2</a>
</div>
<div class="stepwizard-step">
<a ng-disabled="step2Disabled;" ui-sref="step3" type="button" class="btn btn-primary btn-circle active-step-wizard">3</a>
</div>
<div class="stepwizard-step">
<a ng-disabled="step3Disabled;" ui-sref="step4" type="button" class="btn btn-primary btn-circle active-step-wizard">4</a>
</div>
<div class="stepwizard-step">
<a ng-disabled="step4Disabled;" ui-sref="step5" type="button" class="btn btn-primary btn-circle active-step-wizard">5</a>
</div>
<div class="stepwizard-step">
<a ng-disabled="step5Disabled;" ui-sref="step6" type="button" class="btn btn-primary btn-circle active-step-wizard">6</a>
</div>
</div>
应用程序.js
$scope.step2Disabled = true;
$scope.step3Disabled = true;
$scope.step4Disabled = true;
$scope.step5Disabled = true;
但是只要当前步骤的表单验证有效,使用这种方法就不会enabled
进行下一步。我该如何解决这个问题?谢谢
更新
我尝试这个解决方案:
测试1:
<div class="stepwizard-step">
<a ng-disabled="step3Disabled;step3Form.$invalid;" ui-sref="step4" type="button" class="btn btn-primary btn-circle active-step-wizard">4</a>
</div>
测试1结果:
它仅在我在当前步骤中ng-disabled
有效,在表单验证有效时有效
测试2:
<div class="stepwizard-step">
<a ng-disabled="step3Disabled || step3Form.$invalid;" ui-sref="step4" type="button" class="btn btn-primary btn-circle active-step-wizard">4</a>
</div>
测试2结果:
当我在上一步时,此步骤的链接被完全禁用。但是当我在这一步并且表格有效时,下一步的链接仍然被禁用。