AngularJS提交json
这是一个带有angularjs的表单AngularJS提交json,json,angularjs,Json,Angularjs,这是一个带有angularjs的表单 名字: 姓氏: 重置 表单={{user}} 函数formController($scope){ $scope.master={firstName:“John”,lastName:“Doe”}; $scope.reset=函数(){ $scope.user=angular.copy($scope.master); }; $scope.reset(); } 您可以使用$http将您的模式(本例中的用户)直接发布为JSON 如果您所有的文本字段都保存在用
名字:
姓氏:
重置
表单={{user}}
函数formController($scope){
$scope.master={firstName:“John”,lastName:“Doe”};
$scope.reset=函数(){
$scope.user=angular.copy($scope.master);
};
$scope.reset();
}
您可以使用$http将您的模式(本例中的用户)直接发布为JSON
如果您所有的文本字段都保存在用户模式中,那么您可以在提交表单之前通过调用下面的函数删除其中一个属性
$scope.remove = function (user) {
delete $scope.user.firstName;//the output here is user with only lastname
}