2

我正在尝试以下示例/演示,并且在我的 chrome 控制台中不断收到此错误:

Error: Non-assignable model expression: undefined (directive: datepicker)

在执行期间我没有收到任何 404。

使用的代码基于:

http://angular-ui.github.io/bootstrap/#/modal

或者

http://plnkr.co/edit/?p=preview

我的模态模板中的代码:

<pre>Selected date is: <em>{{dt | date:'fullDate' }}</em></pre>
    <div class="well well-small pull-left" ng-model="dt">
        <datepicker min="minDate" show-weeks="showWeeks"></datepicker>
    </div>

模态控制器中的代码:

$scope.today = function () {
        $scope.dt = new Date();
    };
    $scope.today();

    $scope.showWeeks = true;
    $scope.toggleWeeks = function () {
        $scope.showWeeks = !$scope.showWeeks;
    };

    $scope.toggleMin = function () {
        $scope.minDate = ($scope.minDate) ? null : new Date();
    };
    $scope.toggleMin();

    $scope.dateOptions = {
        'year-format': "'yy'",
        'starting-day': 1
    };
4

1 回答 1

3

解决方案是在 datepicker 中定义 ng-model:

<div class="well well-small pull-left" >
        <datepicker min="minDate" show-weeks="showWeeks" ng-model="dt"></datepicker>
    </div>
于 2013-08-07T20:32:20.180 回答