Angularjs引导日期选择器:选择多个日期 [英] Angularjs bootstrap datepicker: Select multiple dates

查看:1043
本文介绍了Angularjs引导日期选择器:选择多个日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用的角度UI带日期选择器。如何选择从日期选择一个以上的日期,并返回该值作为数组

I am trying to use the angular UI strap datepicker. How to select more than one date from the datepicker and return the value as an array.

<一个href=\"http://mgcrea.github.io/angular-strap/#/datepicker\">http://mgcrea.github.io/angular-strap/#/datepicker

推荐答案

您可以使用gm.datepickerMultiSelect指令,围绕UI的自举日期选择器的指令,加入多选功能包。

You can use gm.datepickerMultiSelect directive, that wraps around ui-bootstrap datepicker directive, adding multi-select feature.

<div ng-controller='AppCtrl'>
    <datepicker ng-model='activeDate' multi-select='selectedDates'></datepicker>
</div>


var myApp = angular.module('myApp',['gm.datepickerMultiSelect']);

function AppCtrl($scope) {
    $scope.activeDate;

    //THIS IS WHERE YOU CAN INITIALIZE VALUES
    $scope.selectedDates = [new Date().setHours(0, 0, 0, 0), new Date(2015, 2, 20).setHours(0, 0, 0, 0), new Date(2015, 2, 10).setHours(0, 0, 0, 0), new Date(2015, 2, 15).setHours(0, 0, 0, 0)];

    $scope.removeFromSelected = function (dt) {
        $scope.selectedDates.splice($scope.selectedDates.indexOf(dt), 1);
    }
}

有在我的博客上这样的文章 http://irhadbabic.com/?p=351
此外,这里的工作的jsfiddle,您可以使用 http://jsfiddle.net/prdkvp7u/4/

There's an article on this on my blog http://irhadbabic.com/?p=351 Also, here's working JSFiddle that you can use http://jsfiddle.net/prdkvp7u/4/

这篇关于Angularjs引导日期选择器:选择多个日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆