アイテムのリストがあり、アイテムの1つをクリックするとモーダルダイアログが表示されますユーザーが何らかの変更を加えて[閉じる]または[変更を保存]のいずれかをクリックします。AngularJS:データバインディングモーダル - 「保存」をクリックした場合のみ変更を保存します。「キャンセル」をクリックすると変更を忘れます
問題は、ユーザーが「閉じる」をいくつか変更してクリックすると、データバインディングが瞬間的なので、ビューがバインドされているモデルに反映されているということです。
「変更を保存」をクリックしたときに更新を延期し、バインドを実行するにはどうすればよいですか、「キャンセル」をクリックすると変更を忘れてしまいます。
私のモーダルダイアログのコードはそうのようなものです:
<div ui-modal class="fade static" ng-model="modalShown" id="myModal" data-backdrop="static">
<div class="modal-header">
<button type="button" class="close" ng-click="closeModal()" aria-hidden="true">×</button>
<h3>{{selectedClientFeature.feature.type}}</h3>
</div>
<div class="modal-body">
<ul class="unstyled columnlist">
<li ng-repeat="country in countriesForEdit">
<input type="checkbox" ng-model="country.selected"> {{country.name}}
</li>
</ul>
</div>
<div class="modal-footer">
<a ng-click="closeModal()" class="btn">Close</a>
<a ng-click="saveChanges()" class="btn btn-primary">Save changes</a>
</div>
</div>
おかげで、 ショーン