title: ionic restful authentication to POST and get data from php
body: <p>im working on an ionic project to create android and ios app.
  im new in ionic and need help to understand how to make a login trough restful services hosted on my server.</p>
  
  <p>the restful uses this auth for every <code>POST</code> or <code>PUT</code> request:</p>
  
  <pre><code>username: admin
  pass: 123123
  </code></pre>
  
  <p>so i am testing a <code>POST</code> request. i have no idea how to authenticate.
  the serverside is set up and running. and the api had been tested and no bug. (tested using cocoa restclient)</p>
  
  <p>ok. this is my app.js</p>
  
  <pre><code>angular.module('tapp', ['ionic'])
  .config(function($stateProvider, $urlRouterProvider){
    $stateProvider
     .state('testapp', {
       url: "/tapp",
       abstract: true,
       templateUrl: "template/menu.html",
       controller: 'MenuCtrl'
  })
  .state('tapp.home', {
        url: '/home',
        views: {
            'tappMenu': {
                templateUrl: 'template/home.html',
                controller: 'HomeCtrl'
            }
        }
  })
  .state('tapp.dash', {
        url: '/dash',
        views: {
            'tappMenu': {
                templateUrl: 'template/dash.html',
                controller: 'DashCtrl'
            }
        }
  })
  
  $urlRouterProvider.otherwise('/tapp/home');
  </code></pre>
  
  <p>here is my controller:</p>
  
  <pre><code>.controller('HomeCtrl', function($scope, $http){
      $scope.formData = [] // just testing post data
      $scope.submit = function(){
        var data = $scope.formData.push($scope.inputData);
        $http.post('http://localhost/tapp-server/posted', data);
     };
  }
  </code></pre>
  
  <p>my php function (using codeigniter rest server)</p>
  
  <pre><code>public function posted_post()
  {
      $this-&gt;response(json_encode($_POST), 200);
  }
  </code></pre>
  
  <p>the issue here is, i dont know how to apply the basic restful authentication whenever the app will post the data to the php because whenever it post the data, i get error as "not authorized". </p>
  
  <p>for other data such as getting the data using <code>GET</code>, i receive the data and processed flawlessly. only on this <code>POST</code> part i am in confusion.</p>