Angularjs 如何将uibmodal与作用域子参数一起使用?
使用angular boostrap的uibmodal,我想为我的模态提供一组命名空间的作用域参数。我需要这些作用域参数存在于我的父级中,以便传递给其他控制器,但我也不希望模态能够访问我的整个父级作用域。所以我真正想做的是:Angularjs 如何将uibmodal与作用域子参数一起使用?,angularjs,angularjs-scope,angular-ui,Angularjs,Angularjs Scope,Angular Ui,使用angular boostrap的uibmodal,我想为我的模态提供一组命名空间的作用域参数。我需要这些作用域参数存在于我的父级中,以便传递给其他控制器,但我也不希望模态能够访问我的整个父级作用域。所以我真正想做的是: //parent controller $scope.selector = { ... } var modalInstance = $uibModal.open({ animation: false, controller: 'SelectorController
//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
有一个模式可以实现我想要的吗?有一些选项,您可以将参数从当前范围传递到模式范围,只需在控制器的参数中添加currentUserId
resolve: {
currentUserId: function () {
return row.entity._id;
}
}
我使用的解决方案是使用
$rootScope.$new()
模块实际创建一个新的范围变量
这允许我用
var modalInstance = $uibModal.open({
animation: false,
controller: 'SelectorController',
scope: $scope.selector,
templateUrl: 'selector.tpl.html'
});
我的模态现在有一个可以使用的名称空间范围,但是对该范围所做的所有更改都可以从我的父范围中获得