title: How to declare Object within $scope AngularJS
body: <p>I'm using AngularJS and I'm trying to create a template where I have an implicit object that calls <strong>test</strong> and inside <strong>test</strong> I have an array that I want to repeat when I call a function inside my Controller, but I'm getting <strong>undefined error</strong> when I'm trying do push an object inside the array.</p>
  
  <p>Here is the example of my code:</p>
  
  <pre><code>&lt;body ng-app="MyApp" ng-controller"MyController"&gt;
      &lt;input ng-model="person.name"&gt;
      &lt;button ng-click="createPhone()"&gt;
      &lt;div data-ng-repeat="phone in person.phones"&gt;
          &lt;input ng-model="phone.number"&gt;
      &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Here is my Controller:</p>
  
  <pre><code>//app.controller...
      $scope.createPhone(){
          var phone = {number: '123456789'};
          $scope.person.phones.push(phone);
      }
  </code></pre>
  
  <p>I'm getting:</p>
  
  <blockquote>
    <p>TypeError: Cannot set property 'phones' of undefined.</p>
  </blockquote>
  
  <p>Could anyone help me?</p>