angularJS使用$http.post()往后台发送数据时,包括{c:$scope.code},但只在input绑定ng-model="code",不申明,不赋值,为什么后台就接不到c呢?
<!DOCTYPE html> <html ng-app="test"> <head> <meta charset="UTF-8"> <title>Document</title> <script src="angular.js"></script> <script> var app=angular.module("test",[]); app.controller('get', ['$http','$scope', function($http,$scope){ $scope.ajax=function (){ $http.post('a.php',{ a:'123', b:'as', c:$scope.code }).then(function (res){ console.log(res); },function (res){ console.log(res); }); }; }]); </script> </head> <body ng-controller="get"> <input type="text" ng-model="code"><button ng-click="ajax()">点击</button> </body> </html>
yuanfengjituan
相关分类