我不明白为什么uuid和datetime没有从我的控制器绑定到我的视图。但这并不是必需的,我可以将它们添加到控制器中的对象上。问题是我不知道该怎么做。我需要添加.dt& .CivilCaseId to the newCivilCase。感谢
//Generate Unique Id
$scope.newCivil = [];
$scope.newCivil.CivilCaseId = uuid2.newuuid();
console.log($scope.newCivil.CivilCaseId);
//Todays Date
$scope.newCivil.dt = new Date();
console.log($scope.newCivil.dt);
//Post Civil Case
$scope.newCivil = new Civil();
$scope.addCivilCase = function () {
$scope.newCivil.$save(function () {
console.log($scope.newCivil); $state.go('home');
});
};
答案 0 :(得分:1)
在你的第一行看来,你设置了
$scope.newCivial = [];
但在那之后,你设置了
$scope.newCivil = new Civil(); //return object previous 'newCivil' is covered by this statement.
建议您将代码更改为:
//Generate Unique Id
$scope.newCivil = new Civil();
$scope.newCivil.CivilCaseId = uuid2.newuuid();
$scope.newCivil.dt = new Date();
console.log($scope.newCivil.dt);
//Post Civil Case
$scope.addCivilCase = function () {
$scope.newCivil.$save(function () {
console.log($scope.newCivil); $state.go('home');
});
};