Angularjs 模式和功能无法正常工作

Angularjs modal and function dont work properly

我有一个从模态调用的函数,该函数获取一个值并将其放入文本框中。当我从页面调用时该功能有效,但当我从模态调用时该功能不起作用。

$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');
  };
});