programing

ui.bootstrap.datepicker가 열려 있고 모드에서 작동하지 않음

linuxpc 2023. 3. 7. 21:10
반응형

ui.bootstrap.datepicker가 열려 있고 모드에서 작동하지 않음

Bootstrap UI Datepicker 디렉티브를 사용하고 있으며, 원래 예시와 같이 Datepicker 팝업을 여는 Datepicker 버튼을 사용하려고 합니다만, 모달 창에서는 동작하지 않습니다.

'플런커' 참조

내가 뭘 잘못하고 있지?

다음으로 변경:is-open="opened"대상:

is-open="$parent.opened"

고정 데모

따라서 HTML의 관련 스니펫은 다음과 같습니다.

      <div class="input-group">

          <input type="text" class="form-control" 
                 datepicker-popup="dd.MM.yyyy"
                 ng-model="dt"
                 is-open="$parent.opened"
                 ng-required="true"
                 close-text="Close" />
          <span class="input-group-btn">
          <button style="height:34px;" class="btn btn-default" ng-click="open()">
          <i class="icon-calendar"></i></button> <b><- button not working</b>
          </span>
        </div>

작동하려면 시간 초과를 넣어야 했습니다.

function toggleStart($event) {
    $event.preventDefault();
    $event.stopPropagation();
    $timeout(function () {
        vm.isStartOpen = !vm.isStartOpen;
    });
}

템플릿은 다음과 같습니다.

<input type="text" class="form-control"
        datepicker-popup ng-model="vm.startDate"
        is-open="vm.isStartOpen" />
<span class="input-group-btn">
    <button type="button" class="btn btn-default"
            ng-click="vm.toggleStart($event)">
        <i class="glyphicon glyphicon-calendar"></i>
    </button>
</span>

datepicker 디렉티브는 외부에서 접근할 수 없는 독자적인 스코프를 작성합니다.이 문제를 해결하려면 사용하세요.

$parent.isopen 

또는 일부 개체 속성 이름을 사용하여 다음과 같은 프로토타입 상속을 방지합니다.

$scope.config.isopen=true;

ng-model="config.isopen"대신ng-model="isopen".

또한 아이콘별로 달력 보기를 초기화할 수도 있습니다.

HTML

<p class="input-group" ng-disabled="invoiceDateDisable">
    <input is-open="opened" type="text" datepicker-popup="M/d/yyyy" ng-model="Date" datepicker-options="dateOptions" />
    <span class="input-group-btn">
        <button type="button" class="btn btn-default" ng-click="open()"><i class="glyphicon glyphicon-calendar"></i></button>
    </span>
</p>

자바스크립트

$scope.open = function () {
    $scope.opened = true;
};

당신은 정말 필요 없어요.open기능:

    <div class="input-group">
        <input type="text" class="form-control"
               datepicker-popup="dd.mm.yyyy"
               ng-model="dt"
               is-open="$parent.opened"
               ng-required="true"
               close-text="Close" />
        <span class="input-group-btn">
        <button style="height:34px;" class="btn btn-default" ng-click="$parent.opened=!$parent.opened">
        <i class="icon-calendar"></i></button> <b><- button not working</b>
        </span>
      </div>

언급URL : https://stackoverflow.com/questions/20212813/ui-bootstrap-datepicker-is-open-not-working-in-modal

반응형