2016-09-23 8 views
3

私はionic accordion Listを使用していますので、フォーム入力はデータベースに空のまま送信されます。私は 'ng-repeat = "グループをグループで使用しないと、データをデータベースに保存できます。そして、私はかなりinsert.phpに問題がないと確信しています。私は誰かがmysqlに空のデータよりもデータを送るためにこれを手助けしたい。グループ配列に問題があり、コントローラに入力値が認識されませんIONICアコーディオンリスト+ Angular JS + PHP Form Post

<ion-content ng-controller="CheckOutCtrl"> 
       <form> 
         <ion-list> 
          <!--Step 1 Billing Details-->   
          <div ng-repeat="group in groups"> 
           <ion-item class="item-stable checkout item ng-binding active" ng-click="toggleGroup(group)" ng-class="{active: isGroupShown(group)}"> 
            <i class="icon" ng-class="isGroupShown(group) ? 'ion-minus' : 'ion-plus'"></i> 
            &nbsp; 
            {{group.name}} 
           </ion-item> 
           <ion-item class="item-accordion" ng-repeat="item in group.items" ng-show="isGroupShown(group)"> 
            <input ng-required="true" ng-model="firstname" class="dumbie" type="text" placeholder="{{item.subName}}"> 
            <span class="error" ng-show="myForm.first_name.$error.required">First name is required!</span> 

            <input ng-required="true" ng-model="lastname" class="dumbie" type="text" placeholder="{{item.subLName}}"> 
            <div role="alert"> <span class="error" ng-show="myForm.last_name.$error.required"> Last name is required!</span> </div> 
            <input ng-required="true" ng-model="email" class="dumbie" type="text" placeholder=" {{item.subEmail}}"> 
            <div role="alert"> <span class="error" ng-show="myForm.email.$error.required"> Email is required!</span> </div> 

            <input class="dumbie" ng-model="telephone" type="text" placeholder=" {{item.subTelephone}}"> 

           </ion-item> 
          </div> 
     </ion-list> 
     </form> 
     </ion-content> 

Controller-> 

.controller('CheckOutCtrl', function ($scope, $http) { 
      $scope.insertdata=function(){ 
         var link = 'http://edu.local/fb_store/www/templates/insert.php'; 
         $http.post(link,{"firstname":$scope.firstname,"lastname":$scope.lastname,"email":$scope.email,"telephone":$scope.telephone}) 
           .success(function(data,status,headers,config){ 
            console.log("Data inserted successfully"); 
         }); 
        }; 


      $scope.groups = []; 


      $scope.groups = [ 
       {name: 'Step 1: Billing Details', id: 1, items: [{subName: 'First Name', subLName: 'Last Name', subEmail: 'Email', subTelephone: 'Telephone', subFax: 'Fax', subCompany: 'Company', subAddress1: 'Address 1', subAddress2: 'Address 2', subCity: 'City', subPostal: 'Postal Code', subCountry: 'Sri Lanka', subRegion: 'Northern Province', subId: '1-1'}]} 
       // { name: 'Step 5: Confirm Order', id: 1, items: [{ subName: 'SubGrup1', subId: '1-1' }, { subName: 'SubGrup1', subId: '1-2' }]}, 
      ]; 

      $scope.toggleGroup = function (group) { 
       if ($scope.isGroupShown(group)) { 
        $scope.shownGroup = null; 
       } else { 
        $scope.shownGroup = group; 
       } 
      }; 
      $scope.isGroupShown = function (group) { 
       return $scope.shownGroup === group; 
      }; 

     }); 

答えて

0

オブジェクトを使用してすべてのng-modelコンテンツを試してみてください。

<ion-item> 
    <input ng-required="true" ng-model="object.firstname" class="dumbie" type="text" placeholder="{{item.subName}}"> 
    <input ng-required="true" ng-model="object.lastname" class="dumbie" type="text" placeholder="{{item.subLName}}"> 
    <input ng-required="true" ng-model="object.email" class="dumbie" type="text" placeholder=" {{item.subEmail}}"> 
    <input class="dumbie" ng-model="object.telephone" type="text" placeholder=" {{item.subTelephone}}"> 
</ion-item> 

app.controller('CheckOutCtrl', function ($scope, $http) { 
    $scope.object={}; 
    $scope.insertdata=function(){ 
     var link = 'http://edu.local/fb_store/www/templates/insert.php'; 
     $http.post(link,$scope.object) 
      .success(function(){ 
       console.log("Data inserted successfully"); 
     })           
     }); 
    }; 
});