【问题标题】:Post start and stop time into mysql(sequelize) using NodeJS使用 NodeJS 将启动和停止时间发布到 mysql(sequelize)
【发布时间】:2018-05-31 18:01:38
【问题描述】:

我正在构建一个项目管理应用程序,我想跟踪用户工作的开始和停止时间。

所以我在 UI 中有两个按钮,开始和停止如果用户单击 开始 按钮,下面的函数将获取当前时间

$scope.start =function(){
     $scope.begin = moment(new Date());
}

如果用户点击STOP按钮,下面这个函数会得到当前时间

$scope.stop =function(){
    $scope.end = moment(new Date());
}

所以我想在这种类型的对象中获取两个数据 $scope.begin 和 $scope.end :

{

    time:[

        { begin: 3:59:1 Dec/18/2017 ; end:5:59:1 Dec/18/2017 },
        //if user click again start and stop i want another object dynamically
        { begin: 5:59:1 Dec/18/2017 ; end:6:59:1 Dec/18/2017 }
        { begin: 5:59:1 Dec/18/2017 ; end:6:59:1 Dec/18/2017 }
        { begin: 5:59:1 Dec/18/2017 ; end:6:59:1 Dec/18/2017 }
        //dynamically want add this objects by user operations

    ]

}

如何做到这一点我正在使用 angularjs 和 nodejs

【问题讨论】:

    标签: javascript arrays angularjs json node.js


    【解决方案1】:

    这很简单,因为您已经完成了!

    //create your time data object
    //or maybe get it from your server
    $scope.timeData = {
      time:[]
    }
    
    
    $scope.start =function(){
         $scope.begin = moment(new Date());
    }
    
    $scope.stop =function(){
        $scope.end = moment(new Date());
        $scope.timeData.time.push({
          begin: $scope.begin,
          end: $scope.end
        })
        
        //and maybe post your timeData to server in order to save them.
    }

    【讨论】:

      猜你喜欢
      • 2016-12-19
      • 2018-02-09
      • 2019-11-14
      • 2018-10-14
      • 2012-07-31
      • 1970-01-01
      • 1970-01-01
      • 2020-06-03
      • 1970-01-01
      相关资源
      最近更新 更多