【发布时间】:2016-02-25 07:29:14
【问题描述】:
我有使用 Angular 以 json 格式输出数据的表单,没有数据库。现在无论该表单的输出是什么,我都想将其发送到某个服务器这是代码,例如我想将其发送到服务器 192.80.36.4。如何使用帖子来做到这一点
controller definition code
<body ng-app="submitExample">
<script>
angular.module('submitExample', [])
.controller('ExampleController', ['$scope', function($scope) {
$scope.list = [];
$scope.text = '';
$scope.submit = function() {
if ($scope.text) {
$scope.list.push(this.text);
$scope.text = '';
}
};
}]);
</script>
</script>
<form ng-submit="submit()" ng-controller="ExampleController">
Enter latitude:
<input type="text" ng-model="text" name="text" />
<input type="submit" id="submit" value="Submit" />
<pre>list={{list| json}}</pre>
</form>
【问题讨论】:
标签: angularjs json angularjs-scope http-post form-submit