title: Cannot Set Property of Undefined Member
body: <p>Moving along in <a href="https://rads.stackoverflow.com/amzn/click/com/1449344852" rel="noreferrer" rel="nofollow noreferrer">AngularJS</a>, I get a JavaScript error on the <code>// ERROR</code> line below.</p>
  
  <p>Why do I get <code>Cannot set property 'show' of undefined</code>? </p>
  
  <pre><code>&lt;html ng-app&gt;
  &lt;body&gt;
  
      &lt;script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.1/angular.min.js"&gt;
        &lt;/script&gt;
  
      &lt;div ng-controller='DeathrayMenuController'&gt;
          &lt;button ng-click='toggleMenu()'&gt;Toggle Menu&lt;/button&gt;
          &lt;ul ng-show='menuState.show'&gt;
              &lt;li ng-click='stun()'&gt;Stun&lt;/li&gt;
              &lt;li ng-click='disintegrate()'&gt;Disintegrate&lt;/li&gt;
              &lt;li ng-click='erase()'&gt;Erase from history&lt;/li&gt;
          &lt;/ul&gt;
      &lt;div/&gt;
  
      &lt;script&gt;
      function DeathrayMenuController($scope) { 
          $scope.menuState.show = false;       // ERROR HERE
  
          $scope.toggleMenu = function() { 
              $scope.menuState.show = !$scope.menuState.show;
          };
      }
      &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>