I am working on a login form and if the user enters invalid credentials we want to mark both the email and password fields as invalid and display a message that says the log
In new version of material 2 which its control name starts with mat prefix setErrors() doesn't work, instead Juila's answer can be changed to:
formData.form.controls['email'].markAsTouched();