这是代码。 我不知道什么是错误的代码,它不工作。我猜测头有一些问题,但语法是正确的。没有-DB(数据库)需要在json中显示输出并将其输出到其他服务器,如“www.hashserver.com”,但使用角度
<script>
angular.module('submitExample', [])
.controller('ExampleController', ['$scope', '$http', function($scope, $http) {
$scope.list = [];
$scope.text = '';
$scope.submit = function() {
if ($scope.text) {
$scope.list.push(this.text);
$scope.text = '';
$http.post("www.sendtohashserver.com/db",method: "POST", {headers: {'Content-Type': 'application/json'} $scope.list).success(function(data, status) {
console.log(data);
})
}
};
}]);
</script>
<form ng-submit="submit()" ng-controller="ExampleController">
Enter Name:
<input type="text" ng-model="text" name="text" />
<input type="submit" id="submit" value="Submit" />
<pre>list={{list| json}}</pre>
</form>
“它不工作”:请定义“它不工作”是什么意思?你有错误信息吗?什么都没有发生或什么? –
1)Uncaught SyntaxError:missing)参数列表后 angular.js:38未捕获 2)错误:[$ injector:modulerr] http://errors.angularjs.org/1.5.0/$injector/modulerr?p0 = submitExample&P1 =呃...... ogleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.5.0%2Fangular.min.js%3A20%3A449) – koku19
但我已经检查了所有的语法 – koku19