Ich benutze Angularjs. Mein Problem ist, wenn ich eine neue Option in meinem Dropdown-Menü auswähle, erscheint ein Dialog. Wenn das Ergebnis des Dialogs falsch ist, muss die ausgewählte Dropdown-Option identisch sein. Ideen von anderen Entwicklern werden analysiert. Vielen Dank im Voraus!Angularjs - Wie ändere ich ein Change Event im Dropdown, wenn der Bestätigungsdialog falsch ist?
Siehe mein Code-Snippet:
<div ng-app="myApp" ng-controller="myCtrl">
<select ng-model="myDropDown" ng-change="Dialog()">
<option>a</option>
<option>b</option>
</select>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.Dialog = function() {
var dialog = confirm('Continue?');
if(!dialog) {
\t alert("Option must not change");
/** The problem is the dropdown still select the option. **/
}
}
});
</script>
Nizza Trick! Danke dafür! –