Javascript IONIC:datepicker为同一页面上的两个日期输入选择不同的日期

Javascript IONIC:datepicker为同一页面上的两个日期输入选择不同的日期,javascript,angularjs,datepicker,ionic-framework,Javascript,Angularjs,Datepicker,Ionic Framework,我正在Angular和Ionic的帮助下开发混合移动应用程序。 我使用了离子日期选择器: HTML:我必须在同一页面中使用两个日期选择器输入: <label class="item item-input"> <ionic-datepicker input-obj="datepickerObject"> <input type="text" ng-model="reshedule

我正在Angular和Ionic的帮助下开发混合移动应用程序。 我使用了离子日期选择器: HTML:我必须在同一页面中使用两个日期选择器输入:

<label class="item item-input">
                    <ionic-datepicker input-obj="datepickerObject"> 
                        <input type="text" ng-model="reshedule.StartDate" placeholder="Select Start Date" name="uSDate" required="">
                    </ionic-datepicker>
                </label>
                <br>
                   <label class="item item-input">
                    <ionic-datepicker input-obj="datepickerObject"> 
                        <input type="text" ng-model="reshedule.EndDate" placeholder="Select End Date" name="uEDate" required="">
                    </ionic-datepicker>
                </label>
我需要根据日期选择更新输入。 但在任何一个日期输入上进行选择都会对这两个字段进行更新。
如何管理两个输入将显示不同的日期

只需定义两个DatePickerObject,每个对象都有自己的回调函数

$scope.datepickerObject = {
        titleLabel: 'Title',  //Optional
        todayLabel: 'Today',  //Optional
        closeLabel: 'Close',  //Optional
        setLabel: 'Set',  //Optional
        setButtonType : 'button-assertive',  //Optional
        todayButtonType : 'button-assertive',  //Optional
        closeButtonType : 'button-assertive',  //Optional
        inputDate: new Date(),  //Optional
        mondayFirst: true,  //Optional
        disabledDates: disabledDates, //Optional
        weekDaysList: weekDaysList, //Optional
        monthList: monthList, //Optional
        templateType: 'popup', //Optional
        showTodayButton: 'true', //Optional
        modalHeaderColor: 'bar-positive', //Optional
        modalFooterColor: 'bar-positive', //Optional
        from: new Date(2012, 8, 2), //Optional
        to: new Date(2018, 8, 25),  //Optional
        callback: function (val) {  //Mandatory
            datePickerCallback(val);
        },
        //dateFormat: 'dd-MM-yyyy', //Optional
        dateFormat: 'yyyy-MM-dd', //Optional
        closeOnSelect: false, //Optional
    }

$scope.datepickerObject2 = {
        titleLabel: 'Title',  //Optional
        todayLabel: 'Today',  //Optional
        closeLabel: 'Close',  //Optional
        setLabel: 'Set',  //Optional
        setButtonType : 'button-assertive',  //Optional
        todayButtonType : 'button-assertive',  //Optional
        closeButtonType : 'button-assertive',  //Optional
        inputDate: new Date(),  //Optional
        mondayFirst: true,  //Optional
        disabledDates: disabledDates, //Optional
        weekDaysList: weekDaysList, //Optional
        monthList: monthList, //Optional
        templateType: 'popup', //Optional
        showTodayButton: 'true', //Optional
        modalHeaderColor: 'bar-positive', //Optional
        modalFooterColor: 'bar-positive', //Optional
        from: new Date(2012, 8, 2), //Optional
        to: new Date(2018, 8, 25),  //Optional
        callback: function (val) {  //Mandatory
            datePickerCallback2(val);
        },
        //dateFormat: 'dd-MM-yyyy', //Optional
        dateFormat: 'yyyy-MM-dd', //Optional
        closeOnSelect: false, //Optional
    }

var disabledDates = [
        new Date(1437719836326),
        new Date(),
        new Date(2015, 7, 10), //months are 0-based, this is August, 10th!
        new Date('Wednesday, August 12, 2015'), //Works with any valid Date formats like long format
        new Date("08-14-2015"), //Short format
        new Date(1439676000000) //UNIX format
    ];

var weekDaysList = ["Sun", "Mon", "Tue", "Wed", "thu", "Fri", "Sat"];

var monthList = ["Jan", "Feb", "March", "April", "May", "June", "July", "Aug", "Sept", "Oct", "Nov", "Dec"];

var datePickerCallback = function (val) {
    if (typeof(val) === 'undefined') {
        console.log(' : No date selected');
    } else {
        console.log('Selected date is : ', val);
        $scope.reshedule.StartDate = val;  

}

 var datePickerCallback2 = function (val) {
        if (typeof(val) === 'undefined') {
            console.log(' : No date selected');
        } else {
            console.log('Selected date is : ', val);
            $scope.reshedule.EndDate = val;  
    }

};
还可以更改html

<label class="item item-input">
                    <ionic-datepicker input-obj="datepickerObject"> 
                        <input type="text" ng-model="reshedule.StartDate" placeholder="Select Start Date" name="uSDate" required="">
                    </ionic-datepicker>
                </label>
                <br>
                   <label class="item item-input">
                    <ionic-datepicker input-obj="datepickerObject2"> 
                        <input type="text" ng-model="reshedule.EndDate" placeholder="Select End Date" name="uEDate" required="">
                    </ionic-datepicker>
                </label>


<label class="item item-input">
                    <ionic-datepicker input-obj="datepickerObject"> 
                        <input type="text" ng-model="reshedule.StartDate" placeholder="Select Start Date" name="uSDate" required="">
                    </ionic-datepicker>
                </label>
                <br>
                   <label class="item item-input">
                    <ionic-datepicker input-obj="datepickerObject2"> 
                        <input type="text" ng-model="reshedule.EndDate" placeholder="Select End Date" name="uEDate" required="">
                    </ionic-datepicker>
                </label>