您的位置:首页 > Web前端 > AngularJS

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);//返回的数据

        })

    }

    }])
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  angularjs