title: How to push object into an array using AngularJS
body: <p>I am trying to do use the angular push function but it is not working. </p>
  
  <p>I want to add strings (or objects) into an array. </p>
  
  <p>I searched for basic examples here at Stack Overflow but I couldn't find it. </p>
  
  <p>Can anyone correct my code or write a very basic example?</p>
  
  <p>Here is my example.</p>
  
  <p><strong>This is the HTML code:</strong></p>
  
  <pre><code>&lt;form ng-controller="TestController as testCtrl ng-submit="testCtrl.addText(myText)"&gt;
      &lt;input type="text" value="Lets go"&gt;
      &lt;button type="button"&gt;Add&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>This is the Java Script code:</strong></p>
  
  <pre><code>(function() {
      var app = angular.module('test', []);
  
      app.controller('TestController', function() {
          this.arrayText = {
              text1: 'Hello',
              text2: 'world',
          }
  
          this.addText = function(text) {
              arrayText.push(this.text);
          }
      });
  })();
  </code></pre>