无法关闭我的bootstrap $ uibModalInstance,它的值是unifind

时间:2016-07-18 14:18:29

标签: angularjs twitter-bootstrap

我正在使用带有bootstap的angularjs

模态控制器:

'use strict';
angular.module('users').controller('userModelController',
        [ '$scope', 'row', function($scope, row, $uibModalInstance) {
            $scope.row = row;

            $scope.cancel = function($uibModalInstance) {
                $uibModalInstance.dismiss('cancel');
            };
        },

        ]);

控制器代码打开我的窗口

this.openUser = function(row) {
                                $scope.row = row;
                                var userInstance = $uibModal
                                .open({
                                    animation : $scope.animationsEnabled,
                                    templateUrl : './user_model',
                                    controller : 'userModelController',
                                    backdrop : true,
                                     windowClass: 'monitoring-modal',
                                    resolve : {
                                         row: function () {
                                              return row;
                                            }
                                    }
                                });
                                 userInstance.result.then(function (row) {
                                     $scope.row = row;
                                 });
                            };

我正在使用弹出窗口编辑表格行 现在我在窗口中得到行值,但是当我点击关闭以关闭窗口时,我得到uibModalInstance是unifine

我的窗口

<div class="modal-footer">
    <button class="btn btn-primary" type="button" ng-click="ok()">OK</button>
    <button class="btn btn-warning" type="button" ng-click="cancel()">Cancel</button>
</div>

2 个答案:

答案 0 :(得分:1)

您尚未注入模态实例[ '$scope', 'row','$uibModalInstance', function($scope, row, $uibModalInstance)

答案 1 :(得分:0)

在您的控制器中使用[ '$scope', 'row','$uibModalInstance', function($scope, row, $uibModalInstance)

此外,this.openUser使用controller: ['$scope', 'row', '$uibModalInstance']

this.openUser = function(row) { $scope.row = row; var userInstance = $uibModal .open({ animation : $scope.animationsEnabled, templateUrl : './user_model', controller: ['$scope', 'row', '$uibModalInstance', ''userModelController'], backdrop : true, windowClass: 'monitoring-modal', resolve : { row: function () { return row; } } }); userInstance.result.then(function (row) { $scope.row = row; }); };