2016-03-06 45 views
1

使用angular-boostrap的uibmodal,我想給我的模態一個命名空間的範圍參數集合。我需要這些範圍參數來生活在我的父母傳遞給其他控制器,但我也不希望我的模式有權訪問我的整個父範圍。所以我真正想做的事情是這樣的:如何在範圍子參數中使用uibmodal?

//parent controller 
$scope.selector = { ... } 

var modalInstance = $uibModal.open({ 
    animation: false, 
    controller: 'SelectorController', 
    scope: $scope.selector 
    templateUrl: 'selector.tpl.html' 
}); 

但是我得到:

angular.min.js:111 TypeError: c.$new is not a function 
at angular.bootstrap-tpls.min.js:8 

有沒有達到我想要的一種模式?

回答

1

有一些選項,你可以從你目前的範圍,模態範圍傳遞參數,可以只添加currentUserId內PARAM您的控制器

resolve: { 
     currentUserId: function() { 
      return row.entity._id; 
     } 
} 
0

我是真正創建一個新的範圍變量,去解決方案的在$rootScope.$new()模塊documented here

這讓我實例化我與模式

var modalInstance = $uibModal.open({ 
    animation: false, 
    controller: 'SelectorController', 
    scope: $scope.selector, 
    templateUrl: 'selector.tpl.html' 
}); 

我的模態現在有一個可以使用的命名空間範圍,但是對於該範圍所做的所有更改都可以從我的父作用域中獲得。