获取值并传递给api ionic angularJS

时间:2016-07-11 18:13:19

标签: javascript php angularjs curl ionic-framework

我有一张表格:

<form name="loginform" novalidate class="css-form">
  <label class="item item-input item-stacked-label">
    <span class="input-label">Email</span>
    <input type="email" name="email" ng-model="user.username" placeholder="Email" required>
             <p class="error validationerror"
      ng-show="loginform.email.$invalid && loginform.email.$touched">
      Must be a valid email</p>
  </label>
  <label class="item item-input item-stacked-label">
    <span class="input-label">Password</span>
    <input type="password" name="password" ng-model="user.password" placeholder="Password" required>
    <p class="error validationerror"
      ng-show="loginform.password.$invalid && loginform.email.$touched">
      Password is required</p>
  </label>

</div>
{{value}}
<input type="submit" ng-click="Login(user)" class="button button-dark marginauto loginformbtn" value="Login">
</form>

我想要做的是这个我想抓住user.username和user.password并且我想把它们传递给api我知道如何抓住它们但我不知道如何将它们作为POST发送与PHP中的cURL一样使用URL。

这是我拥有的角度js代码:

$scope.Login = function(user) {
    $scope.value = {};
};

请帮助谢谢

1 个答案:

答案 0 :(得分:-1)

在angularjs中执行$http.post方法

你问题中的

 $scope.login= function(user){

         var value = {
                        "UserName":user.username,
                        "PassWord":user.password
                     };


          $http.post("place your http service here",value)
                .success(function(res){
                   console.log(res);
                 })
                .error(function(res){
                   console.log(res);
                 });

要了解有关$http官方document

的更多信息