<tfoot id='yPNLV'></tfoot>

  • <small id='yPNLV'></small><noframes id='yPNLV'>

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

        将数据从 Angular 模态的控制器传回主控制器

        Pass data from an Angular modal#39;s controller back to the main controller(将数据从 Angular 模态的控制器传回主控制器)
          <tfoot id='U6bVf'></tfoot>

        • <legend id='U6bVf'><style id='U6bVf'><dir id='U6bVf'><q id='U6bVf'></q></dir></style></legend>
            <tbody id='U6bVf'></tbody>

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

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

                • 本文介绍了将数据从 Angular 模态的控制器传回主控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  事情就是这样.我无法将数据从角度模态传递回我需要的控制器.下面给出的代码.

                  Here is the thing. I am not able to pass data from angular modal back to the controller where i need it. the codes given below.

                  控制器端

                  'use strict'
                  var DataMod = angular.module('Data', ["angularGrid", 'ui.bootstrap.contextMenu', 'ui.bootstrap']);
                  DataMod.controller('DataController', ['$scope', '$compile', '$uibModal', '$log','$rootScope', '$http', function ($scope, $compile, $uibModal,$log, $rootScope, $http, ngUtilityService) {
                  
                  
                  
                  //user first clicks on Add button. A modal opens up. ModalInstanceCtrl is the controller used.
                  $scope.adduser = function () {
                  var modalInstance = $uibModal.open({
                      templateUrl: 'myModalContent.html',
                      controller: ModalInstanceCtrl
                  });
                   //response data should be available here.  
                  };
                  
                  
                  var ModalInstanceCtrl = function ($scope, $uibModalInstance) {
                  //ajax call is made is inside this controller and i get a response. 
                  //this response is an object. i need to pass this object back to the adduser function. mentioned it above. 
                  };
                  
                  
                  }
                  ]);
                  

                  正如您在上面看到的,有主控制器.我在那里使用了一个模式,它有自己的控制器.我在该模态控制器内进行 ajax 调用并得到响应.

                  As you can see above, there is the main controller. I have used a modal inside there which has its own controller. I make ajax call inside that modals controller and get a response back.

                  我希望该响应可以在 adduser 函数中返回,以便我可以使用该数据.但是,似乎一旦 adduser 函数启动,它就会转到 ModalInstanceCtrl 并在那里结束执行.它根本不会回到 adduser 函数.我需要一种方法来回到 adduser 函数.

                  I want that response as a result to be available back at the adduser function so that i can work with that data. However, it seems that once the adduser function starts, it goes to the ModalInstanceCtrl and ends its execution there. It doesnt come back to the adduser function at all. I need a way to get back to the adduser function.

                  谁能告诉我如何实现这一点.还有如何将对象响应从 ModalInstanceCtrl 传递到 adduser 函数内的主控制器.

                  Can anyone let me know how to achieve this. Also how to pass the object response from ModalInstanceCtrl to the main controller inside adduser function.

                  推荐答案

                  看起来您正在使用 Angular Bootstrap Modal,是吗?首先,我会设置它,以便模态控制器与主控制器分离.其次,您缺少将响应从模态传递到主控制器所需的承诺.您可以在此处的文档中阅读有关返回模式实例的信息:https://angular-ui.github.io/bootstrap/#/modal

                  It looks like you are using the Angular Bootstrap Modal, yes? First, I would set it up so that the modal controller is separated out from the main controller. Second, you are missing the promise needed to pass the response from the modal to the main controller. You can read about the return modal instance in the docs here: https://angular-ui.github.io/bootstrap/#/modal

                  这是来自 Angular Bootstrap plunkr 的示例代码:http://plnkr.co/edit/nGjBtMp33pFDAQ6r7Tew?p=info

                  This is the example code from the Angular Bootstrap plunkr: http://plnkr.co/edit/nGjBtMp33pFDAQ6r7Tew?p=info

                  angular.module('ui.bootstrap.demo', ['ngAnimate', 'ui.bootstrap']);
                  angular.module('ui.bootstrap.demo').controller('ModalDemoCtrl', function ($scope, $uibModal, $log) {
                  
                    $scope.items = ['item1', 'item2', 'item3'];
                  
                    $scope.animationsEnabled = true;
                  
                    $scope.open = function (size) {
                  
                  var modalInstance = $uibModal.open({
                    animation: $scope.animationsEnabled,
                    templateUrl: 'myModalContent.html',
                    controller: 'ModalInstanceCtrl',
                    size: size,
                    resolve: {
                      items: function () {
                        return $scope.items;
                      }
                    }
                  });
                  
                  modalInstance.result.then(function (selectedItem) {
                    $scope.selected = selectedItem;
                  }, function () {
                    $log.info('Modal dismissed at: ' + new Date());
                  });
                  };
                    $scope.toggleAnimation = function () {
                      $scope.animationsEnabled = !$scope.animationsEnabled;
                    };
                  
                  });
                  
                  // Please note that $uibModalInstance represents a modal window (instance) dependency.
                  // It is not the same as the $uibModal service used above.
                  
                  angular.module('ui.bootstrap.demo').controller('ModalInstanceCtrl', function ($scope, $uibModalInstance, items) {
                  
                    $scope.items = items;
                    $scope.selected = {
                      item: $scope.items[0]
                    };
                  
                    $scope.ok = function () {
                      $uibModalInstance.close($scope.selected.item);
                    };
                  
                    $scope.cancel = function () {
                      $uibModalInstance.dismiss('cancel');
                    };
                  });
                  

                  这篇关于将数据从 Angular 模态的控制器传回主控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Draw border around nontransparent part of image on canvas(在画布上的图像不透明部分周围绘制边框)
                  dragging and resizing an image on html5 canvas(在 html5 画布上拖动图像并调整其大小)
                  What#39;s the difference between a boolean as primitive and a boolean as property of an object?(作为原始对象的布尔值和作为对象属性的布尔值有什么区别?)
                  I want to do animation of an object along a particular path(我想沿特定路径对对象进行动画处理)
                  How to upload image into HTML5 canvas(如何将图像上传到 HTML5 画布中)
                  How to show a running progress bar while page is loading(如何在页面加载时显示正在运行的进度条)
                • <tfoot id='A6NMU'></tfoot>
                          <bdo id='A6NMU'></bdo><ul id='A6NMU'></ul>

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

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

                            <tbody id='A6NMU'></tbody>

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