Observing the Observable

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 />";&gt;}[...]

In the preceding code, ...

Get ASP.NET Core 2 and Angular 5 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.