重置模型时,我的表单中不会更新Ng模型

时间:2015-11-03 13:07:46

标签: angularjs

我在使用表格时遇到了一些问题,因为我的模型在重置时会丢失。 Plunker查看问题结果:plunker

function cancel() {
    vm.selectedCommande = angular.copy(originalCommande);
    $scope.commandeForm.$setPristine();
    $scope.commandeForm.$setUntouched();
}

我可能会遗漏一些东西,但我无法理解,我会很感激somme帮助。

2 个答案:

答案 0 :(得分:1)

您在表单中使用type =“reset”。如果要从angularJS重置表单,请从按钮中删除该attr。

答案 1 :(得分:0)

你试过这个吗?

function cancel() {
   vm.selectedCommande.observations = 'Former observations';
   $scope.commandeForm.$setPristine();
   $scope.commandeForm.$setUntouched();
} 
});
相关问题