Angularjs不用入门也可使用的方法-提交数据
2017-05-15 14:16
344 查看
<div ng-controller="formController">
<input type="text" ng-model="data" placeholder="提交的数据"/>
<input type="submit" ng-click="addData()">
</div>
<script type="text/javascript" src="js/angularjs.js"></script>
<script>
//app是ng-app的名称
angular.module('app',[])
.controller('formController',[$scope,$http,function($scope,$http){
//$scope.data 提交过去的数据
$scope.addData=function(){
$http.post('controller.java中对应的接口',$scope.data).success(function(response){
console.log(response);//返回的数据
})
}
}])
<input type="text" ng-model="data" placeholder="提交的数据"/>
<input type="submit" ng-click="addData()">
</div>
<script type="text/javascript" src="js/angularjs.js"></script>
<script>
//app是ng-app的名称
angular.module('app',[])
.controller('formController',[$scope,$http,function($scope,$http){
//$scope.data 提交过去的数据
$scope.addData=function(){
$http.post('controller.java中对应的接口',$scope.data).success(function(response){
console.log(response);//返回的数据
})
}
}])
相关文章推荐
- jQuery ajax中使用serialize() 方法提交表单数据
- php中使用Curl、socket、file_get_contents三种方法POST提交数据
- WebBrowser使用POST方法提交数据
- AngularJS —— 使用 ngResource、RESTful APIs 和 Spring MVC 框架提交数据
- jQuery使用serialize(),serializeArray()方法取得表单数据+字符串和对象类型两种表单提交的方法
- Python模仿POST提交HTTP数据及使用Cookie值的方法
- 使用Curl、socket、file_get_contents三种方法POST提交数据
- MVC中使用Ajax提交数据 Jquery Ajax方法传值到action
- 使用Curl、socket、file_get_contents三种方法POST提交数据
- 使用Curl、socket、file_get_contents三种方法POST提交数据
- Struts:把页面数据提交到Form的原理及使用方法
- MVC中使用Ajax提交数据 Jquery Ajax方法传值到action
- jQuery ajax中使用serialize() 方法提交表单数据
- C++使用POST方法向网页提交数据-----C++发送HTTP数据获取Google天气预报
- 使用Dojo实现页面不刷新提交数据时避免前台缓存的方法
- 使用Curl、socket、file_get_contents三种方法POST提交数据
- jQuery ajax中使用serialize() 方法提交表单数据
- MVC中使用Ajax提交数据 Jquery Ajax方法传值到action
- jQuery ajax中使用serialize() 方法提交表单数据
- WebBrowser使用POST方法提交数据