AngularJS POST GET example

You can use this in Controller file to use get & post method.
var turtle_data = {Sun:"English"}     
var turtle_url = "http://127.0.0.1:7000/exercise/test/user_data/123/ccy"
$http({
        method:"post",
        url: turtle_url,
        data: turtle_data
    }).
        success(function(data, status) {
            alert(JSON.stringify(data)+'#post#'+status+'#1')
        }).
        error(function(data, status) {
            alert(JSON.stringify(data)+'#post#'+status+'#1')
        });

post

get

$http({
      method: "get",
      url: turtle_url
  }).
      success(function(data, status) {
          alert(JSON.stringify(data)+'#get#'+status+'#0')
      }).
      error(function(data, status) {
          alert(JSON.stringify(data)||"Request failed"+'#get#'+status+'#0')
      });
  


你可能感兴趣的:(AngularJS,html5,controller,post,get)