ng-click无法使用uib-datepicker-popup

时间:2017-04-19 09:25:20

标签: angularjs angular-ui-bootstrap uidatepicker

我使用uib-datepicker-popup。单击此代码上的输入字段或日历图像时,没有任何内容:

<div>
        <label for="startDate">Start</label>
        <div>
            <input type="text"
                id="startDate"
                uib-datepicker-popup="dd/MM/yyyy"
                datepicker-mode="'month'"
                datepicker-template-url="project/datepicker/datepicker.html"
                datepicker-popup-template-url="project/datepicker/popup.html"
                show-button-bar="false" 
                show-weeks="false"
                is-open="startDate.opened"
                on-open-focus="true" 
                datepicker-append-to-body="true" 
                name="dateFrom" 
                min-date="minStartDate"
                placeholder=""
                ng-model="startDate"
                uib-datepicker-popup="yyyy-MM-dd"
            />
            <span>
                <button type="button" ng-click="startDate.opened = !startDate.opened;">
                    <i aria-hidden="true"></i>
                </button>
            </span>
        </div>
   </div>

你对这个问题有什么看法吗? 谢谢!

1 个答案:

答案 0 :(得分:0)

我不确定,但如果参考文档:

ng-model $ - 日期对象。必须是Javascript Date对象。你可以使用   uibDateParser服务,以协助进行字符串到对象的转换。https://angular-ui.github.io/bootstrap/

在您的情况下,它不是日期

尝试创建其他属性以保持is-open(例如$ scope.isOpen)状态:

<div>
    <label for="startDate">Start</label>
    <div>
        <input type="text"
            id="startDate"
            uib-datepicker-popup="dd/MM/yyyy"
            datepicker-mode="'month'"
            datepicker-template-url="project/datepicker/datepicker.html"
            datepicker-popup-template-url="project/datepicker/popup.html"
            show-button-bar="false" 
            show-weeks="false"
            is-open="isOpen"
            on-open-focus="true" 
            datepicker-append-to-body="true" 
            name="dateFrom" 
            min-date="minStartDate"
            placeholder=""
            ng-model="startDate"
            uib-datepicker-popup="yyyy-MM-dd"
        />
        <span>
            <button type="button" ng-click="isOpen = !isOpen">
                <i aria-hidden="true"></i>
            </button>
        </span>
    </div>