如何使用angular和php将输入ng-model传递给服务

时间:2016-04-24 06:59:06

标签: angularjs ionic-framework

我有$ http.get的问题从视图中的输入字段值中检索json。继承我的代码

我的表格

 <div class="container">
  <div class="col">
        <div class="app-logo"><img src="img/logo.svg"></div> 
        <div class="list list-inset removePM">
          <label class="item item-input">
          <input type="text" ng-model="user.username" placeholder="NRIC" > 
          </label>
          <label class="item item-input">
          <input type="password" ng-model="user.password" placeholder="Password" > </label>
        </div>
        <div class="loginButton"><button class="button ion-unlocked button-block button-balanced custom-button" ng-click="login(user);"> Login </button>  </div>
   </div>

我的控制器

 angular.module('starter.controllers', [])
 .controller('LoginCtrl',  function($scope, LoginService, 
    $ionicPopover, $timeout,  $location, $ionicPopup, Profiles){

    $scope.login = function (user) {
    Profiles.grab(user); 
  };
})

我的服务

 .factory('Profiles', function($http, $location, sessionService, $window, LoginService) {

  var profiles = {content:null}; 

  $http.get('http://192.168.0.113/soap-request/soap.php?username='+ user.username +'&password=' + user.password +'').success(function(data) {                
  profiles.content = data;
   return true;
 });  
      grab: function(data, $http) {
      return profiles;
    }
 });

0 个答案:

没有答案