angularjs - 从 Controller 关闭 Angular 引导模式窗口

标签 angularjs angularjs-directive angular-ui bootstrap-modal meanjs

我的模式窗口中有一个联系表单。成功发布请求后,我想关闭 modal自动地。我正在使用 MEAN.JS

这是我的 Controller

angular.module('core').controller('FormCtrl',['$scope','$http', function($scope,$http) {

 $scope.postMail = function (data) {

    $http.post('/mail', data).
      success(function(data, status, headers, config) {
        alert('success');
        //close function....??
      }).

      error(function(data, status, headers, config) {

      });
 };

}]);//formController ends

$http.post 成功后如何关闭我的模式?

最佳答案

我有东西给你

使用:- $modalStack

然后调用$modalStack.dismissAll();

简单plunker

我在 plunkler 中使用了 $timeout 你可以在任何地方使用它,比如 $http :-)

Doc

关于angularjs - 从 Controller 关闭 Angular 引导模式窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28498146/

相关文章:

javascript - AngularJS ng-click 被 {{$index}} 破坏

javascript - 带有 javascript 的卡片的 RTL

angularjs - ng-class 在指令中不起作用

javascript - 与 AngularJS 的指令绑定(bind)

angularjs - Angular-UI 和 Bootstrap : change class based on class

javascript - 如何开始编写像 mohiomap 这样的东西?

javascript - 指令内带有事件的动态 HTML 元素

Angular-UI UI-Select 停止将事件类应用于第一项的默认行为

javascript - 如何使用 css 在 angular typeahead 中对齐元素

javascript - 在 AngularJS 1.X 中使用 Monaco 编辑器