0

I tried going through the bwlow tutorial to do form validation in angular 2 https://angular.io/docs/ts/latest/guide/forms.html

But it just returns a blank page.

However, if I replace the following line

<form *ngIf="active" (ngSubmit)="onSubmit()" #heroForm="ngForm">

with

<form>

at least i get some form elements appearing. The difficult part is that there seems to be no error messages that can direct me to the problem.

Can anyone help?

1 Answer 1

2

What is the state of active variable? It must be true because you have used the ngIf:

<form *ngIf="active" (ngSubmit)="onSubmit()" #heroForm="ngForm">

Everything seems to work fine, but your form is just not rendered because active is not present/is false.

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

1 Comment

The component class should contain - public active = true; to initialize ngIf. Its easy to miss because it is not mentioned in the reactive forms docs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.