title: Passing POST data from ionic framework to CodeIgniter Rest API
body: <p>From last two days i'm try to post the data from my Ionic app to CodeIgniter rest api using $http. But my post data goes empty. I refere some link. But failed to seolve. Below is my code.</p>
  
  <p>My ionic view</p>
  
  <pre><code> &lt;div class="list"&gt;
         &lt;label class="item item-input item-md-label" placeholder="Username" highlight-color="balanced" type="text"&gt;
                &lt;input class="md-input" type="text" ng-model="user.name"&gt;
                &lt;span class="input-label"&gt;Username&lt;/span&gt;
                &lt;div class="hightlight hightlight-calm"&gt;&lt;/div&gt;
              &lt;/label&gt;
  
              &lt;label class="item item-input item-md-label" placeholder="Password" highlight-color="energized" type="password"&gt;
                &lt;input class="md-input" type="password" ng-model="user.password"&gt;
                &lt;span class="input-label"&gt;Password&lt;/span&gt;
                &lt;div class="hightlight hightlight-calm"&gt;&lt;/div&gt;
              &lt;/label&gt;
  
          &lt;/div&gt;
          &lt;div class="padding"&gt;
              &lt;button ng-click="doLogin(user)" class="button button-full button-assertive ink"&gt;Login&lt;/button&gt;
          &lt;/div&gt;
  </code></pre>
  
  <p>Ionic Controller code :</p>
  
  <pre><code>.controller('LoginCtrl', function($scope, $timeout, $stateParams, ionicMaterialInk, $http, baseUrl) {
      $scope.$parent.clearFabs();
      $timeout(function() {
          $scope.$parent.hideHeader();
      }, 0);
      ionicMaterialInk.displayEffect();
  
    $scope.doLogin = function(user) {
  
      $http({
        method : "POST",
        url : "http://localhost/vas_api/index.php/api/User/index/"+user.name
      }).then(function mySucces(response) {      
        console.log(response)
      });
    }    
  })
  </code></pre>
  
  <p>CodeIgniter controller code : </p>
  
  <pre><code>&lt;?php
  defined('BASEPATH') OR exit('No direct script access allowed');
  
  require APPPATH . '/libraries/REST_Controller.php';
  
  use Restserver\Libraries\REST_Controller;
  
  class User extends REST_Controller {
  
      public function index_post() {
        if(!$this-&gt;input-&gt;post('name')) {
          $this-&gt;response(null, 400);
        }
  
        $data = array(
          'name' =&gt; $this-&gt;input-&gt;post('name')
        );
  
        $id = $this-&gt;User_model-&gt;insertUser($this-&gt;input-&gt;post('name'));
  
        if(!is_null($id)) {
          $this-&gt;response(array('response' =&gt; $id), 200);
        }  else {
          $this-&gt;response(array('response', 'Null values'), 400);
        }
      }   
  }
  </code></pre>
  
  <p>Codeigniter model code :</p>
  
  <pre><code>&lt;?php 
  
  defined('BASEPATH') OR exit('No direct script access allowed');
  
  class User_model extends CI_Model { 
  
    function insertUser($data) {
      $this-&gt;db-&gt;insert('user',array('name' =&gt; $data));
      $userId = $this-&gt;db-&gt;insert_id();
  
      return $userId;
    }
  
  }
  
  ?&gt;
  </code></pre>
  
  <p>Please help me to solve this issue. I'm using advance CodeIgniter version 3 Thanks in advance</p>