如何将日期从日历推送到angularJS中的startAt()函数中 angular.module(“…”,[“…”) .控制器(“主”,主); 函数main($scope,$firebaseArray){ $scope.assign=函数(){ $scope.assigned=$scope.deviceName; }; $scope.today=函数(){ //必须在isostring之前设置小时数 $scope.dth=新日期(); $scope.test=力矩($scope.dth).format('YYYY-MM-DD'); log($scope.test); //此console.log用于检查日期格式是否正确 }; $scope.today(); $scope.inlineOptions={ customClass:getDayClass, minDate:新日期(), 《秀周》:没错 }; $scope.open1=函数(){ $scope.popup1.opened=true; }; $scope.formats=['dd-MMMM-yyyy','yyyy/MM/dd','dd.MM.yyyy','shortDate']; $scope.format=$scope.formats[0]; $scope.altInputFormats=['M!/d!/yyyy']; $scope.popup1={ 开放:假 }; $scope.dateOptionsM={ 年份:'嗯', 开始日期:1, minDate:新日期(2018,0,1,0,0,0,0), minMode:“月” }; $scope.dateOptionsY={ 格式年:'yyy', 开始日期:1, //minDate:从哪一天开始 minDate:新日期(2018,0,1,0,0,0,0), minMode:“年” }; 函数getDayClass(数据){ 变量日期=data.date, mode=data.mode; 如果(模式=='day'){ var dayToCheck=新日期(Date).setHours(0,0,0,0); 对于(变量i=0;i

如何将日期从日历推送到angularJS中的startAt()函数中 angular.module(“…”,[“…”) .控制器(“主”,主); 函数main($scope,$firebaseArray){ $scope.assign=函数(){ $scope.assigned=$scope.deviceName; }; $scope.today=函数(){ //必须在isostring之前设置小时数 $scope.dth=新日期(); $scope.test=力矩($scope.dth).format('YYYY-MM-DD'); log($scope.test); //此console.log用于检查日期格式是否正确 }; $scope.today(); $scope.inlineOptions={ customClass:getDayClass, minDate:新日期(), 《秀周》:没错 }; $scope.open1=函数(){ $scope.popup1.opened=true; }; $scope.formats=['dd-MMMM-yyyy','yyyy/MM/dd','dd.MM.yyyy','shortDate']; $scope.format=$scope.formats[0]; $scope.altInputFormats=['M!/d!/yyyy']; $scope.popup1={ 开放:假 }; $scope.dateOptionsM={ 年份:'嗯', 开始日期:1, minDate:新日期(2018,0,1,0,0,0,0), minMode:“月” }; $scope.dateOptionsY={ 格式年:'yyy', 开始日期:1, //minDate:从哪一天开始 minDate:新日期(2018,0,1,0,0,0,0), minMode:“年” }; 函数getDayClass(数据){ 变量日期=data.date, mode=data.mode; 如果(模式=='day'){ var dayToCheck=新日期(Date).setHours(0,0,0,0); 对于(变量i=0;i,angularjs,firebase-realtime-database,angular-bootstrap,angular-calendar,Angularjs,Firebase Realtime Database,Angular Bootstrap,Angular Calendar,所以我想做的是将日历上设置的日期推送到startAt()中函数。但是,经过测试,我意识到两个日志只显示了一次。这意味着该值没有改变。但是,在HTML页面上,该值确实改变了,并且它使用了$scope.dth。我有没有办法根据日历显示更改这些值?我使用的是角度引导UI。谢谢如果您包含与此控制器代码相关联的HTML(例如,如何连接uib datepicker),则答案可能会有所帮助。但是,从您提供的内容来看,您似乎已将$scope.dth绑定到uib datepicker,然后您正在观看test,它显

所以我想做的是将日历上设置的日期推送到
startAt()中
函数。但是,经过测试,我意识到两个日志只显示了一次。这意味着该值没有改变。但是,在HTML页面上,该值确实改变了,并且它使用了
$scope.dth
。我有没有办法根据日历显示更改这些值?我使用的是角度引导UI。谢谢

如果您包含与此控制器代码相关联的HTML(例如,如何连接
uib datepicker
),则答案可能会有所帮助。但是,从您提供的内容来看,您似乎已将
$scope.dth
绑定到
uib datepicker
,然后您正在观看
test
,它显然没有共享对
$scope.dth
的引用(即,如果后者更改,前者不会)。啊,好的,通过将其直接绑定到$scope.dth,它可以工作了!谢谢!
angular.module('...', ['...'])
    .controller('main', main);

function main($scope, $firebaseArray) {
    $scope.assign = function() {
        $scope.assigned = $scope.deviceName;
    };
    $scope.today = function () {
        // must put to set hours before isostring
        $scope.dth = new Date();
        $scope.test = moment($scope.dth).format('YYYY-MM-DD');
        console.log($scope.test);
        // this console.log is to check if the date format is correct
    };
    $scope.today();

    $scope.inlineOptions = {
        customClass: getDayClass,
        minDate: new Date(),
        showWeeks: true
    };

    $scope.open1 = function () {
        $scope.popup1.opened = true;
    };

    $scope.formats = ['dd-MMMM-yyyy', 'yyyy/MM/dd', 'dd.MM.yyyy', 'shortDate'];
    $scope.format = $scope.formats[0];
    $scope.altInputFormats = ['M!/d!/yyyy'];

    $scope.popup1 = {
        opened: false
    };

    $scope.dateOptionsM = {
        formatYear: 'MM',
        startingDay: 1,
        minDate: new Date(2018, 0, 1, 0, 0, 0, 0),
        minMode: 'month'
    };

    $scope.dateOptionsY = {
        formatYear: 'yyyy',
        startingDay: 1,
        // minDate: start from which date
        minDate: new Date(2018, 0, 1, 0, 0, 0, 0),
        minMode: 'year'
    };

    function getDayClass(data) {
        var date = data.date,
            mode = data.mode;
        if (mode === 'day') {
            var dayToCheck = new Date(date).setHours(0, 0, 0, 0);

            for (var i = 0; i < $scope.events.length; i++) {
                var currentDay = new Date($scope.events[i].date).setHours(0, 0, 0, 0);

                if (dayToCheck === currentDay) {
                    return $scope.events[i].status;
                }
            }
        }

        return '';
    }


    $scope.$watch('[assigned, test]', function(values) {
        //UI for calendar function
        var newtest = values[1];
        var value = values[0];
        var newRef = firebase.database().ref('editedData').child(value);

        var hourRef = newRef.child('H');

        $scope.halfhourlyData = $firebaseArray(hourRef.orderByChild('timestamp').limitToLast(48).startAt(newtest));
        console.log(newtest);
        // this console log only displays once
        $scope.halfhourlyData.$loaded();