在我的 angularjs 应用程序中,我使用 UI Bootstrap 来创建模态。我将范围和自定义控制器传递到模态中,它显示了来自原始范围的数据,但无法执行其任何功能。我有主控制器:
myapp.controller('WsCtrl', function WsCtrl($scope, $location, todoStorage, filterFilter, $modal, $log) {
在控制器中,我有下一个:
$scope.items = ['item1', 'item2', 'item3'];
$scope.open = function () {
var modalInstance = $modal.open({
templateUrl: 'partials/users.html',
scope: $scope,
controller: ModalInstanceCtrl,
resolve: {
items: function () {
return $scope.items;
},
users: function(){
return $scope.users;
},
CurrentDate: function(){
return $scope.CurrentDate;
}
}
});
modalInstance.result.then(function (selectedItem) {
console.log(selectedItem);
}, function () {
$log.info('Modal dismissed at: ' + new Date());
});
};
而且我在控制器之外还有另一个功能:
var ModalInstanceCtrl = function ($scope, $modalInstance, items) {
$scope.items = items;
$scope.users = users;
$scope.CurrentDate = CurrentDate;
$scope.selected = {
item: $scope.items[0]
};
$scope.num = 11;
$scope.ok = function () {
$modalInstance.close($scope);
};
$scope.cancel = function () {
$modalInstance.dismiss('cancel');
};
};
当我将范围传递给模态时 - 我可以看到我的所有用户,但我无法添加一个,因为我的原始范围内的功能出现问题。