title: AngularJS .isUndefined
body: <pre><code>if( angular.isDefined( $scope.user.id ) ){ var data = ({ id : $scope.user.id }) ; }
  </code></pre>
  
  <p>Produces Error: </p>
  
  <pre><code>TypeError: Cannot read property 'id' of undefined
  </code></pre>
  
  <p>$scope.user is going to be undefined sometimes - it will only have a value if the user is logged in. I have tried typeOf, === 'undefined' and angular.isDefined / Undefined throughout my code and cannot find a solution that always works when checking a angular property that may be undefined or null. </p>
  
  <p>Thanks for the help I am sure will follow.</p>