Extending the activity log

Reacting to the Form Model changes is not the only thing we can do; we can extend our subscriptions to observe any form control as well. Here's a further upgrade we can perform on our current activity log implementation to demonstrate that:

[...]// react to changes in the form.Text controlthis.form.get("Text")!.valueChanges    .subscribe(val => {        if (!this.form.dirty) {            this.log("Text control has been loaded with initial               values.");        }        else {            this.log("Text control was updated by the user.");        }    });[...]

Place the preceding code at the end of the createForm() method, right below the Form Model subscription we implemented early on; this will add further log lines within the Form activity log, all related to the changes ...

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.