У меня есть функция, которая вызывается из модального, функция принимает значение и помещает его в текстовое поле. Функция работает, когда я вызываю со страницы, но когда я звоню из модального файла, это не работает.
$scope.accept = function (id) {
console.log($scope.nomco);
$scope.NIF = id;
//$scope.modalOptions.close();
};
И кнопка:
<button ng-click="accept('prueba');"><strong>Seleccionar</strong></button>
Взгляните на пример с страницы 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');
};
});
accept('prueba')
может видетьaccept
?