将 md-dialog 替换为模态 ui bootstrap,试图找到 locals 属性副本

Replaced md-dialog with modal ui bootstrap,trying to find the locals attribute duplica

我不得不用 angular 模型 UI bootstrap 替换我的 md-dialog。在 md-dialog 中,我使用 locals 属性将 anguler.copy 从主控制器发送到对话框控制器。 我的问题是,如何使用模态 UI bootstrap 获得相同的结果?

md-dialog代码(旧版)

$scope.notefullScreen=function(event){


                        $mdDialog.show({
                        controller: DialogNoteFullscreenController,
                        templateUrl: 'views/schedule/note-fullscreen.html',
                        targetEvent:event,

                        locals: {
                        editNote: angular.copy($scope.noteEdit), 
                        editPtivacy:angular.copy($scope.privacyOptions),
                        detailsFull:$scope.details

                        }        

                    }).then(function () {

                        }, function () {

                        }); 

modal ui 代码:(正在开发新版本,我目前拥有的)

 $scope.notefullScreenNew = function (event) {

                            var modalInstance = $modal.open({
                                templateUrl: 'views/schedule/schedule-extended-note-popup.html',
                                controller: ScheduleService.NotePopupCtrl,
                                targetEvent: event,
                                resolve: {
                                editNote: function () { return angular.copy($scope.noteEdit); },
                                editPtivacy: function() { return angular.copy($scope.privacyOptions); },
                                detailsFull: function(){return $scope.details;}
//                                locals: {
//                                    editNote: angular.copy($scope.noteEdit),
//                                    editPtivacy: angular.copy($scope.privacyOptions),
//                                    detailsFull: $scope.details
                                    // attachmentFull:angular.copy($scope.attachment)

                                }


                            });


                            modalInstance.result.then(function () {

                            }, function () {

                            });
                        };

angular-ui-bootstrap 可以通过 resolve 属性解析模态控制器的局部变量。这些将作为函数参数提供给您的模态控制器函数。

为了适应您的场景,它将变成:

var modalInstance = $modal.open({
                templateUrl: 'views/schedule/schedule-extended-note-popup.html',
                controller: ScheduleService.NotePopupCtrl,
                targetEvent: event,

                resolve: {
                            editNote: function()( {
                                return angular.copy($scope.noteEdit);
                            },
                            editPtivacy: function() {
                                return angular.copy($scope.privacyOptions)
                            },
                            detailsFull: function() {
                                return $scope.details;
                            }
                         }
                    });

然后这些将作为具有相同名称的函数参数传递到您的 NotePopupCtrl(就像注入一样);

旁注:我假设你的属性 editPtivacy 应该是 editPrivacy,而且我认为 angular-ui-bootstrap 不支持targetEvent 属性。