Template-driven with ngModel in Angular

Angular interview exercise on Forms, difficulty 2 of 3. Solve it in the editor beside a worked example; the tests run the moment you do.

FeedbackComponent, template-driven: `rating` (a <select class="rating"> with options 1 to 5, default "5") and `comment` (a <textarea> that is required with at least 10 characters) bound with ngModel inside a form. The submit button is disabled while the form is invalid; submitting sets `sent` to "Thanks! <rating> stars".

Each exercise pairs a worked example with a twin problem to solve in a real editor; the tests run the moment you do. Progress is saved in your browser, and in your account if you sign in.

More Forms in Angular

All Angular exercises · Other languages and frameworks