我有一个从模态调用的函数,该函数接受一个值并将其放在一个文本框中。当我从页面调用但是当我从模态调用时,该功能无效。
$scope.accept = function (id) {
console.log($scope.nomco);
$scope.NIF = id;
//$scope.modalOptions.close();
};
按钮:
<button ng-click="accept('prueba');"><strong>Seleccionar</strong></button>
答案 0 :(得分:0)
查看ui-bootstrap页面中的示例。
//main page controller
angular.module('ui.bootstrap.demo').controller('ModalDemoCtrl', function ($scope, $uibModal, $log) {
$scope.items = ['item1', 'item2', 'item3'];
$scope.animationsEnabled = true;
$scope.open = function (size) {
var modalInstance = $uibModal.open({
animation: $scope.animationsEnabled,
templateUrl: 'myModalContent.html',
controller: 'ModalInstanceCtrl',
size: size,
resolve: {
items: function () {
return $scope.items;
}
}
});
modalInstance.result.then(function (selectedItem) {
$scope.selected = selectedItem;
}, function () {
$log.info('Modal dismissed at: ' + new Date());
});
};
$scope.toggleAnimation = function () {
$scope.animationsEnabled = !$scope.animationsEnabled;
};
});
// Modal controller
//see how the data is being passed from the main controller to the modal controller
angular.module('ui.bootstrap.demo').controller('ModalInstanceCtrl', function ($scope, $uibModalInstance, items) {
$scope.items = items;
$scope.selected = {
item: $scope.items[0]
};
$scope.ok = function () {
$uibModalInstance.close($scope.selected.item);
};
$scope.cancel = function () {
$uibModalInstance.dismiss('cancel');
};
});