title: TypeError Cannot set property of undefined
body: <p>I'm getting a <code>TypeError: Cannot set property 'error' of undefined</code> for the following line of code: <code>this.error = error.code;</code></p>
  
  <p>Here's what I'm trying to do (it's in an Angular Reactive Form, calling a web service):</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>@Component({
    // ...
  })
  export class SignUpComponent implements OnInit {
    // More declarations...
    error: string | null; // I also tried error = '' and error = null
    // Constructor, etc.
  
    public submit() {
  
      this.error = null;
      if (this.signUpForm.valid) {
        // Create an Auth0 user
        this.authService.signUp(this.signUp.value.email, this.signUp.value.password, this.authServiceCallback);
      }
    }
  
    public authServiceCallback(error) {
      if (error) {
        // This will cause an error child component to appear
        this.error = error.code;
      } else {
        // Do something else
      }
    }
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>What am I doing wrong??</p>