ng-form
したがって、ディレクティブを使用して次のステップへのリンクに依存します。しかし、現在のステップ以外の次のステップへのリンクが であることがわかりましたenabled
。
そこで、フラグを使用するように変更しましたng-disabled
。ここに私のコードがあります:
index.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>
app.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 の結果:
前のステップにいるとき、このステップへのリンクは完全に無効になっています。ただし、このステップでフォームが有効な場合、次のステップへのリンクはまだ無効になっています。