title: Angular js with codeigniter
body: <p>I want to show data in a table with angular js. I have tried many code but didn't solve my problem. Please help</p>
  
  <p>Here is my code of <strong>View</strong> page..</p>
  
  <p><strong>Script code</strong></p>
  
  <pre><code>&lt;script&gt;
      var app = angular.module('myApp', []);
      app.controller("customersCtrl", function($scope, $http) {   
      $http.get('&lt;?php echo base_url('items/getRecords'); ?&gt;').
  success(function(data, status, headers, config) {       
      $scope.users = data;
  });
   });
  &lt;/script&gt;
  </code></pre>
  
  <p><strong>HTML Code</strong></p>
  
  <pre><code>  &lt;div ng-app="myApp" ng-controller="customersCtrl"&gt;                
              &lt;table class="datatable table table-striped table-bordered" id="example"&gt;
                  &lt;thead&gt;
                      &lt;tr&gt;                    
                          &lt;th&gt;Product Code&lt;/th&gt;                       
                          &lt;th&gt;Product Name&lt;/th&gt;                           
                      &lt;/tr&gt;
                  &lt;/thead&gt;
                  &lt;tbody&gt;
  
                      &lt;tr class="gradeA" ng-repeat="x in users"&gt;
  
                          &lt;td style="text-align:center;"&gt;{{x.item_code}}&lt;/td&gt;                         
                          &lt;td style="text-align:center;"&gt;{{x.item_name}}&lt;/td&gt;         
  
                      &lt;/tr&gt;
  
                  &lt;/tbody&gt;
              &lt;/table&gt;
  
          &lt;/div&gt;
  </code></pre>
  
  <p><strong>On Controller</strong> </p>
  
  <pre><code> public function getRecords(){
  
      $this-&gt;load-&gt;model('item_model');
      $data=$this-&gt;item_model-&gt;getTransactionData();
      $this-&gt;output-&gt;set_header('Content-type: application/json');
      $this-&gt;output-&gt;set_output(json_encode($data));
  }
  </code></pre>
  
  <p>And finally on <strong>Model</strong> </p>
  
  <pre><code>public function getTransactionData(){
  
  
      $query=$this-&gt;db-&gt;get('ac_itrans');
      return $query-&gt;result();
  
  }
  </code></pre>
  
  <p>Here is Json format of my result:</p>
  
  <pre><code>  [{"itrans_id":"17","cocode":"OFLT","yearcode":"OFLT16","vseries":"S","vnum":"1","vdate":"2015-10-06","linenum":"1","item_type":"services","item_code":"26","item_name":"AC Repair"}];
  </code></pre>
  
  <p>Console log</p>
  
  <p><a href="https://i.stack.imgur.com/VIZc7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VIZc7.png" alt="enter image description here"></a></p>