2

When Creating my first form in Angular2, I get this following Error:

Unhandled Promise rejection: Cannot set property 'stack' of undefined ; Zone: ; Task: Promise.then ; Value: TypeError: Cannot set property 'stack' of undefined

I am using anguilar-cli 1.0.0-beta.25.5. ** here is my code:

import { Component } from '@angular/core';
import {FormControl, FormGroup} from '@angular/forms';

@Component({
  selector: 'app-root',
  template:
    `<div class="container">
           <form [formGroup]="userForm" (ngSubmit)="submitHandler()">
             <div class="form-group">
                <input type="text" class="form-control"       formControlName="username"
  placeholder="username...">
            </div>
          </form>
     </div>`
})
export class AppComponent {
  private userForm : FormGroup;

  constructor(){
    this.userForm = new FormGroup({
      username : new FormControl(),
      password : new FormControl(),
      email : new FormControl(),
    });

  }
}
2
  • There seems to be nothing wrong with this piece of code, syntax-wise. Either the error is elsewhere or has something to do with angular-cli. Commented Jan 20, 2017 at 23:07
  • 2
    Did you import the ReactiveFormsModule in your AppModule? Commented Jan 21, 2017 at 1:08

2 Answers 2

2

Update zone.js to 0.7.6 and you'll see actual error.

Sign up to request clarification or add additional context in comments.

1 Comment

That acually did the work! Now I can see that my error was "Can't bind to 'formGroup' since it isn't a known property of 'form'" - I was missing the ReactiveFormsModule" import in my app.module.ts
1

It might be related to the issue here. https://github.com/angular/angular-cli/issues/3975 . Do backup and try to update to the latest version.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.