Once again the QuestionEditComponent will be our lab rat; open its TypeScript class file and update it with the following highlighted lines:
[...]export class QuestionEditComponent { title: string; question: Question; form: FormGroup; activityLog: string;[...]createForm() { this.form = this.fb.group({ Text: ['', Validators.required] }); this.activityLog = ''; this.log("Form has been initialized."); // react to form changes this.form.valueChanges .subscribe(val => { if (!this.form.dirty) { this.log("Form Model has been loaded."); } else { this.log("Form was updated by the user."); } });}log(str: string) { this.activityLog += "[" + new Date().toLocaleString() + "] " + str + "<br />";>}[...]
In the preceding code, ...