I have a simple one input form like this

```
                    <form class="form" [formGroup]="registerForm" (ngSubmit)="onSubmit()">
                        <div class="row">
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label for="floatEmail">Product Name</label>
                                    <input type="text" class="form-control" id="floatEmail" name="floatEmail" formControlName="name" >
                                    <small class="form-text text-muted danger" *ngIf="f.name.errors.required" >Please enter a name!</small>
                                </div>
                            </div>
                        </div>

                        <div class="form-group">
                            <div class="col-md-12 text-right">
                                <button type="button" class="btn btn-success btn-raised mr-1">Cancel</button>
                                <button type="button" class="btn btn-danger btn-raised" >Submit</button>
                            </div>
                        </div>
                    </form>

```

I just want to validation and console the value.

.ts

```
 registerForm: FormGroup;

  ngOnInit() {
    this.registerForm = this.formBuilder.group({
      name: ['', Validators.required],

  });
  }
  get f() { return this.registerForm.controls; }

  onSubmit() {
    this.submitted = true;
    if (this.registerForm.invalid) {
        return;
    }
    alert('SUCCESS!! :-)\n\n' + JSON.stringify(this.registerForm.value, null, 4));
  }

```

The issue is always showing error I want to show error after click.

Also on console.log, its showing this error

```
TypeError: Cannot read property 'required' of null

```