On Angular 1.3.15我有以下控制器功能:
smartIdApp.controller('SavePersonalCtrl', ['$scope', '$location', 'IPVService', 'PersonalModel', 'RoutingService','IdentityService',
function SavePersonalCtrl($scope, $location, IPVService, PersonalModel, RoutingService, IdentityService) {
$scope.submit = function() {
console.log('SavePersonalCtrl.submit()');
// Duplicate and cache Identity data
var identity = IdentityService.identity;
identity.push(angular.copy($scope.personalData));
if ($scope.personalForm.birthname.$viewValue === "Yes") {
$location.path(PATH_DOB);
} else {
var today = new Date().getTime();
var viewYear = $scope.personalData.birthNameYear;
var viewMonth = $scope.personalData.birthnameMonth;
if (daysBetween(today, viewYear, viewMonth, 1) > NAME_VALIDITY_DAYS) {
$location.path(PATH_DOB);
} else {
$scope.personalData = {};
$scope.personalForm.$setPristine();
console.log($scope.personalForm.birthNameYear.$viewValue + " " + $scope.personalData);
$location.path(PATH_NAMES);
}
}
};
}
]);
应该清除personalData并将personalForm设置为pristine的语句似乎没有效果。记录说:
InitPersonalCtrl()
controllers-personal.js:22 SavePersonalCtrl.submit()
controllers-personal.js:40 2015 [object Object]
为什么这不起作用?