title: Setting Nested Object Values from AngularJS Controller
body: <p>I am trying to set a value of a nested object from my Angular Controller but I keep getting the following error:</p>
  
  <pre><code>Cannot read property 'field0' of undefined
  </code></pre>
  
  <p>The code in my Controller is:</p>
  
  <pre><code>$scope.obj = $scope.obj || {};
  
  $scope.autosave = function(){
      $window.sessionStorage.setItem("experienceOne", $scope.obj.experience.field0);
  }
  </code></pre>
  
  <p>Any idea what I am doing wrong? Im sure its something small but I can't seem figure it out. How can I set the value in a nested object. Just for reference the object structure is like this:</p>
  
  <pre><code>obj{
       name:"",
       experience:{
          field0:"",
          field1:"",
          field2:""
      }
   }
  </code></pre>