<legend id='JhNmO'><style id='JhNmO'><dir id='JhNmO'><q id='JhNmO'></q></dir></style></legend>

          <bdo id='JhNmO'></bdo><ul id='JhNmO'></ul>

        <small id='JhNmO'></small><noframes id='JhNmO'>

        <i id='JhNmO'><tr id='JhNmO'><dt id='JhNmO'><q id='JhNmO'><span id='JhNmO'><b id='JhNmO'><form id='JhNmO'><ins id='JhNmO'></ins><ul id='JhNmO'></ul><sub id='JhNmO'></sub></form><legend id='JhNmO'></legend><bdo id='JhNmO'><pre id='JhNmO'><center id='JhNmO'></center></pre></bdo></b><th id='JhNmO'></th></span></q></dt></tr></i><div id='JhNmO'><tfoot id='JhNmO'></tfoot><dl id='JhNmO'><fieldset id='JhNmO'></fieldset></dl></div>
        <tfoot id='JhNmO'></tfoot>

        Angularjs - 当确认对话框为假时如何取消下拉更改

        时间:2023-09-04
        <i id='c3ofq'><tr id='c3ofq'><dt id='c3ofq'><q id='c3ofq'><span id='c3ofq'><b id='c3ofq'><form id='c3ofq'><ins id='c3ofq'></ins><ul id='c3ofq'></ul><sub id='c3ofq'></sub></form><legend id='c3ofq'></legend><bdo id='c3ofq'><pre id='c3ofq'><center id='c3ofq'></center></pre></bdo></b><th id='c3ofq'></th></span></q></dt></tr></i><div id='c3ofq'><tfoot id='c3ofq'></tfoot><dl id='c3ofq'><fieldset id='c3ofq'></fieldset></dl></div>
        <tfoot id='c3ofq'></tfoot>

        • <legend id='c3ofq'><style id='c3ofq'><dir id='c3ofq'><q id='c3ofq'></q></dir></style></legend>

              <bdo id='c3ofq'></bdo><ul id='c3ofq'></ul>
                <tbody id='c3ofq'></tbody>

                  <small id='c3ofq'></small><noframes id='c3ofq'>

                  本文介绍了Angularjs - 当确认对话框为假时如何取消下拉更改事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在使用 Angularjs.我的问题是当我在下拉列表中选择一个新选项时,会出现一个对话框.如果对话框的结果为 false,则选择的下拉选项必须相同.将分析从其他开发人员那里获得的想法.提前谢谢!

                  I am using Angularjs. My problem is when I select a new option in my dropdown, a dialog will appear. If the result of the dialog is false, the selected dropdown option must be the same. Getting ideas from other devs will be analyzed. Thank you in advance!

                  请参阅下面的代码片段:

                  Refer to my code snippet below:

                  <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) {
                      	    alert("Option must not change");
                              /** The problem is the dropdown still select the option. **/
                          }
                      }
                  });
                  </script>

                  推荐答案

                  这里有一个你可能不知道的技巧:

                  Here is a trick you may not know:

                  ng-change="dialog(myDropDown)"         // pass the NEW value of myDropDown
                  ng-change="dialog('{{myDropDown}}')"   // pass the OLD value of myDropDown
                  

                  当调用 dialog() 时,您可以将之前选择的选项作为参数传递.

                  When calling dialog(), you can pass as a param the previous selected option.

                  然后,如果对话框被取消,只需回滚它.

                  Then, just rollback it if the dialog is cancelled.

                  var app = angular.module('myApp', []);
                  
                  app.controller('myCtrl', function($scope) {
                      $scope.dialog = function(prev) {
                          var dialog = confirm('Continue?');
                          if(!dialog) {
                              $scope.myDropDown = prev;
                              alert("Option must not change");
                          }
                      }
                  });

                  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
                  
                  <div ng-app="myApp" ng-controller="myCtrl">
                    <select ng-model="myDropDown" ng-change="dialog('{{myDropDown}}')">
                      <option>a</option>
                      <option>b</option>
                    </select>
                  </div>

                  这篇关于Angularjs - 当确认对话框为假时如何取消下拉更改事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:jQuery UI Dialog 个人 CSS 样式 下一篇:如何为居中的浮动确认对话框设计 CSS?

                  相关文章

                  最新文章

                  <small id='L2UnA'></small><noframes id='L2UnA'>

                    <i id='L2UnA'><tr id='L2UnA'><dt id='L2UnA'><q id='L2UnA'><span id='L2UnA'><b id='L2UnA'><form id='L2UnA'><ins id='L2UnA'></ins><ul id='L2UnA'></ul><sub id='L2UnA'></sub></form><legend id='L2UnA'></legend><bdo id='L2UnA'><pre id='L2UnA'><center id='L2UnA'></center></pre></bdo></b><th id='L2UnA'></th></span></q></dt></tr></i><div id='L2UnA'><tfoot id='L2UnA'></tfoot><dl id='L2UnA'><fieldset id='L2UnA'></fieldset></dl></div>
                    <tfoot id='L2UnA'></tfoot>

                      • <bdo id='L2UnA'></bdo><ul id='L2UnA'></ul>
                      <legend id='L2UnA'><style id='L2UnA'><dir id='L2UnA'><q id='L2UnA'></q></dir></style></legend>