uib-datepicker-popup在我的角应用程序中无效

时间:2017-09-02 04:33:19

标签: javascript angularjs datepicker angular-ui-bootstrap

uib-datepicker-popup在我的角度应用中不起作用,我在其他控制器中工作

<input ng-click="open($event, 'delivery_time_popup')" type="text" class="form-control" uib-datepicker-popup="dd-MMMM-yyyy" show-weeks="false" ng-model="purchase_order.delivery_time" is-open="delivery_time_popup" datepicker-options="dateOptions" required close-text="Close" placeholder="Select Date">

JS

$scope.open = function ($event, opened) {
        console.log(opened);
        $event.preventDefault();
        $event.stopPropagation();
        $scope[opened] = true;
    };

    $scope.delivery_time_popup = false;

    $scope.dateOptions = {
        formatYear: 'yy',
        startingDay: 1
    };

1 个答案:

答案 0 :(得分:0)

您需要在$scope.delivery_time_popup函数中将open值更改为true。

 $scope.open = function ($event, opened) {
    console.log(opened);
    $event.preventDefault();
    $event.stopPropagation();
    $scope[opened] = true;

    $scope.delivery_time_popup = true; //add this
};
您的html中的

会将ng-click更改为ng-focus

Plnkr example

<强> HTML

<input ng-focus="open($event, 'delivery_time_popup')" type="text" class="form-control" uib-datepicker-popup="dd-MMMM-yyyy" show-weeks="false" ng-model="purchase_order.delivery_time" is-open="delivery_time_popup" datepicker-options="dateOptions" required close-text="Close" placeholder="Select Date">

<强> CONTROLLER

$scope.open = function ($event, opened) {
    console.log(opened);
    $event.preventDefault();
    $event.stopPropagation();
    $scope[opened] = true;

    $scope.delivery_time_popup = true;
};

   $scope.delivery_time_popup = false;

   $scope.dateOptions = {
    formatYear: 'yy',
    startingDay: 1
    };
});
相关问题