angular.js - angular-daterangepicker 取得不到model值
漂亮男人
漂亮男人 2017-05-15 17:07:28
0
1
556

根據文件寫了一個demo,放到生產環境測試發現獲取不到model值,有同樣使用該插件的同學碰到類似問題嗎,求教。

github:https://github.com/fragaria/a...

HTML:

<p ng-controller="AppCtrl">
    <input date-range-picker class="form-control date-picker" type="text" ng-model="date" options="{
        timePicker: true,
        timePickerIncrement: true,
        timePicker24Hour: true,
        timePickerSeconds: true,
        locale: {
            applyLabel : '确定',  
            cancelLabel : '取消',  
            fromLabel : '起始时间',  
            toLabel : '结束时间',  
            customRangeLabel : '自定义',  
            daysOfWeek : [ '日', '一', '二', '三', '四', '五', '六' ],  
            monthNames : [ '一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月' ],  
            format: 'YYYY-MM-DD HH:mm:ss'
        }
    }"/>
    <a href="javascript:;" ng-click="getDate()">save</a>
</p>

JS:

var app = angular.module('test',['daterangepicker']);

app.config(function($interpolateProvider,$httpProvider, $controllerProvider, $compileProvider, $filterProvider, $provide){
 
});

app.controller('AppCtrl',function($scope,$http){

    $scope.getDate = function(){
        console.log($scope.date);
    }

    $scope.$watch('date', function(newDate) {
        console.log('New date set: ', newDate);
    }, false);

});

angular.bootstrap(document,['test']);
漂亮男人
漂亮男人

全部回覆(1)
淡淡烟草味

這個可能是js由js中物件是引用,值是複製的機製造成的

試下把綁定的變數掛載在一個物件上

像github裡面的程式碼一樣

exampleApp.controller('TestCtrl', function ($scope) {
    $scope.datePicker.date = {startDate: null, endDate: null};
}
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!