title: How to push objects in AngularJS between ngRepeat arrays
body: <p>So I'm new to AngularJS and I'm trying to build a very simple list app, where I can create an ng-repeat item list and then push a selected item into another ng-repeat list. Although my problem seems to be very simple I wasn't able to find a proper solution yet. </p>
  
  <p><strong>So here's the simplified markup:</strong></p>
  
  <pre><code>&lt;body ng-app="MyApp"&gt;
   &lt;div id="MyApp" ng-controller="mainController"&gt;
  
      &lt;div id="AddItem"&gt;
           &lt;h3&gt;Add Item&lt;/h3&gt;
  
          &lt;input value="1" type="number" placeholder="1" ng-model="itemAmount"&gt;
          &lt;input value="" type="text" placeholder="Name of Item" ng-model="itemName"&gt;
          &lt;br/&gt;
          &lt;button ng-click="addItem()"&gt;Add to list&lt;/button&gt;
      &lt;/div&gt;
      &lt;!-- begin: LIST OF CHECKED ITEMS --&gt;
      &lt;div id="CheckedList"&gt;
           &lt;h3&gt;Checked Items: {{getTotalCheckedItems()}}&lt;/h3&gt;
  
           &lt;h4&gt;Checked:&lt;/h4&gt;
  
          &lt;table&gt;
              &lt;tr ng-repeat="item in checked" class="item-checked"&gt;
                  &lt;td&gt;&lt;b&gt;amount:&lt;/b&gt; {{item.amount}} -&lt;/td&gt;
                  &lt;td&gt;&lt;b&gt;name:&lt;/b&gt; {{item.name}} -&lt;/td&gt;
                  &lt;td&gt; 
                     &lt;i&gt;this item is checked!&lt;/i&gt;
  
                  &lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
      &lt;/div&gt;
      &lt;!-- end: LIST OF CHECKED ITEMS --&gt;
      &lt;!-- begin: LIST OF UNCHECKED ITEMS --&gt;
      &lt;div id="UncheckedList"&gt;
           &lt;h3&gt;Unchecked Items: {{getTotalItems()}}&lt;/h3&gt;
  
           &lt;h4&gt;Unchecked:&lt;/h4&gt;
  
          &lt;table&gt;
              &lt;tr ng-repeat="item in items" class="item-unchecked"&gt;
                  &lt;td&gt;&lt;b&gt;amount:&lt;/b&gt; {{item.amount}} -&lt;/td&gt;
                  &lt;td&gt;&lt;b&gt;name:&lt;/b&gt; {{item.name}} -&lt;/td&gt;
                  &lt;td&gt;
                      &lt;button ng-click="toggleChecked($index)"&gt;check item&lt;/button&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
      &lt;/div&gt;
      &lt;!-- end: LIST OF ITEMS --&gt;
    &lt;/div&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p><strong>And here goes my AngularJS Script:</strong></p>
  
  <pre><code>var app = angular.module("MyApp", []);
  
  app.controller("mainController",
  
  function ($scope) {
  
  // Item List Arrays
  $scope.items = [];
  $scope.checked = [];
  
  // Add a Item to the list
  $scope.addItem = function () {
  
      $scope.items.push({
          amount: $scope.itemAmount,
          name: $scope.itemName
      });
  
      // Clear input fields after push
      $scope.itemAmount = "";
      $scope.itemName = "";
  
  };
  
  // Add Item to Checked List and delete from Unchecked List
  $scope.toggleChecked = function (item, index) {
      $scope.checked.push(item);
      $scope.items.splice(index, 1);
  };
  
  // Get Total Items
  $scope.getTotalItems = function () {
      return $scope.items.length;
  };
  
  // Get Total Checked Items
  $scope.getTotalCheckedItems = function () {
      return $scope.checked.length;
  };
  });
  </code></pre>
  
  <p>So when I click the button, my toggleChecked() function triggers and it actually pushes something into my checked list. However, it seems to be just an empty object. The function can't get the actual item that I want to push.</p>
  
  <p>What am I doing wrong here?</p>
  
  <p>NOTE: Checking items via click on a button is intended. I don't want to use checkboxes in this case.</p>
  
  <p>You can see the working model here: <a href="http://jsfiddle.net/7n8NR/1/" rel="noreferrer">http://jsfiddle.net/7n8NR/1/</a></p>
  
  <p>Cheers,
  Norman</p>