我正在构建一个项目管理应用程序,我想跟踪用户工作的开始和停止时间。
所以我在 UI 中有两个按钮,START 和 STOP 如果用户单击 START 按钮,下面的函数将获取当前时间
$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
最佳答案
这非常简单,因为您已经完成了!
//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.
}
关于javascript - 使用 NodeJS 将开始和停止时间发布到 mysql(sequelize),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47867704/