控制单选按钮已选择angularjs

时间:2019-03-15 04:28:15

标签: angularjs

收音机“默认运送地址”被选择为默认值,当选择收音机“新运送地址”时,它会弹出一个窗口:“ newAddress”。 关闭“新地址”弹出窗口时,我想将选择的收音机更改为“默认收货地址”。 (将刷新电台选择为默认电台)有什么帮助? enter image description here enter image description here

            <div class="radio text-info mt10 mb20">
              <label>
                <input type="radio" ng-model="form.receiverType" value="SELECT">
                <b data-translate="_Paymen001">Default shipping Address </b>
              </label>
            </div>
            <div class="radio mt10 mb20">
              <label>
                <input type="radio" ng-model="form.receiverType" value="INSERT">
                <b data-translate="_Paymen002">New shipping Address </b>
              </label>
            </div>

点击取消关闭弹出窗口

<button data-dismiss="modal" aria-label="Close" class="btn btn-primary btn-lg ng-scope" type="button" data-translate="_Cancel" ng-click="cancelSaveNewAddss()" style=" margin-top: 20px;">Cancel</button>

事件点击单选按钮

// bind event when change receiverType
          $scope.$watch('form.receiverType', function(newVal, oldVal) {
          switch (newVal) {
            case 'SELECT':
                            $scope.selecteDefaultAddr();
                  break;
            case 'INSERT':
                  $('.modal-receiver-add').modal();
                  break;
            case 'MODIFY':
                // get reciever list
                  $scope.getReceiverList();
                  $('.modal-chondanhba').modal();
                  break;
            default:
                  break;
        }
    }, true);

1 个答案:

答案 0 :(得分:0)

您需要在控制器中处理模态的返回部分.result.then

示例:

$uibModal.open({
  animation: $ctrl.animationsEnabled,
  ariaLabelledBy: 'modal-title',
  ariaDescribedBy: 'modal-body',
  templateUrl: 'myModalContent.html',
  controller: 'ModalInstanceCtrl',
  controllerAs: '$ctrl',
  size: size,
  appendTo: parentElem,
  resolve: {
    items: function () {
      return $ctrl.items;
    }
  }
}).result.then(function (response) {
  // You can get the response from modal.
  // If user clicked the cancel button, set the radio button back to the default.
}, function () {
  // Modal is dismissed with cancel, ESC button or click on the outside of modal.
  // Set the radio button back to the default.
});

更多信息,angularjs bootstrap modal