title: Push json data to existing array in angular js
body: <p>I'm having issues with pushing data to an existing array. You can see I'm posting the data to a table, however, when a user enters an 8 digit barcode, I like to push the data to the table.</p>
  
  <p><img src="https://i.stack.imgur.com/n0dzZ.jpg" alt="enter image description here"></p>
  
  <p><strong>Factory</strong></p>
  
  <pre><code>    angular.module('app.pickUpServ', []).factory('pickUpServ', ['$rootScope', '$http',
      function($rootScope, $http) {
          return {
              getPickUpList: function(data) {
                  $http({
                      method: 'POST',
                      url: 'app/Service/CourierService.asmx/BarcodeList',
                      data: {
                          "bardcodeVal": "",
                          "courierType": "PICKUP",
                          "userName": "aspuser"
                      },
                      contentType: 'application/json; charset=utf-8',
                      dataType: 'json',
                  }).success(data).error(function(error) {
                      console.log('Error - getPickUpList');
                  });
              },
              items: [{
                          "bardcodeVal": "",
                          "courierType": "PICKUP",
                          "userName": "aspuser"
                      }],
              add: function(item) {
                  this.items.push(item);
                  console.log(item);
              }
          };
      }
  ]);
  </code></pre>
  
  <p><strong>Controller</strong> </p>
  
  <pre><code>angular.module('app.scanListCtrl', []).controller('ScanListCtrl', ['$scope', 'pickUpServ',
      function ($scope, pickUpServ) {
          //Get Pick Up Data
          if ($scope.title == 'Pick Up') {
  
              pickUpServ.getPickUpList(function (data) {
                  $scope.items = data.d
              });
  
              $scope.autoAddItem = function () {
                  if (($scope.BarcodeValue + '').length == 8) {
                      pickUpServ.add({
                          "barcodeVal": $scope.BarcodeValue,
                          "courierType": "PICKUP",
                          "userName": "aspuser"
                      });
                      $scope.BarcodeValue = "";
                  }
              };
          }
      }
  ]);
  </code></pre>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>&lt;div ng-controller="ScanListCtrl"&gt;
  &lt;div class="row prepend-top-md"&gt;
      &lt;div class="col-lg-12"&gt;
          &lt;div class="panel panel-default"&gt;
              &lt;div class="panel-heading"&gt;
                  &lt;h3 class="panel-title"&gt;
                      &lt;i class="fa fa-barcode"&gt;&lt;/i&gt;&amp;nbspScan Item&lt;/h3&gt;
              &lt;/div&gt;
              &lt;div class="panel-body"&gt;
                  &lt;div class="input-group input-group-lg"&gt;
                      &lt;input type="number" class="form-control" placeholder="Scan Item" ng-model="BarcodeValue"
                          ng-change="autoAddItem()" is-focus&gt;
                      &lt;span class="input-group-btn"&gt;
                          &lt;button class="btn btn-info" type="button" ng-click="addRow()"&gt;
                              Add Barcode&lt;/button&gt;
                      &lt;/span&gt;&lt;/div&gt;
              &lt;/div&gt;
              &lt;table class="table table-striped table-hover"&gt;
                  &lt;thead&gt;
                      &lt;tr&gt;
                          &lt;th class="text-center" style="width: 3%"&gt;
                              #
                          &lt;/th&gt;
                          &lt;th&gt;
                              &lt;i class="fa fa-barcode"&gt;&lt;/i&gt;&amp;nbspBarcode
                          &lt;/th&gt;
                          &lt;th&gt;
                              &lt;i class="fa fa-medkit"&gt;&lt;/i&gt;&amp;nbspCSN
                          &lt;/th&gt;
                          &lt;th&gt;
                              &lt;i class="fa fa-user"&gt;&lt;/i&gt;&amp;nbspUser
                          &lt;/th&gt;
                          &lt;th&gt;
                              &lt;i class="fa fa-clock-o"&gt;&lt;/i&gt;&amp;nbspDate
                          &lt;/th&gt;
                      &lt;/tr&gt;
                  &lt;/thead&gt;
                  &lt;tbody&gt;
                      &lt;tr ng-repeat="item in items | orderBy:'Id':true:reverse"&gt;
                          &lt;td class="text-center"&gt;
                              [{{item.Id}}]
                          &lt;/td&gt;
                          &lt;td&gt;
                              {{item.BarcodeValue}}
                          &lt;/td&gt;
                          &lt;td&gt;
                              {{item.CSN}}
                          &lt;/td&gt;
                          &lt;td&gt;
                              {{item.LastName + ', ' + item.FirstName}}
                          &lt;/td&gt;
                          &lt;td&gt;
                              {{item.Created}}
                          &lt;/td&gt;
                      &lt;/tr&gt;
                  &lt;/tbody&gt;
              &lt;/table&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p></p>