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 control
this.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 occurred in the Text component.

What we just did here is more than enough to demonstrate the wonders of the valueChanges Observable property; let's move on to the next topic.

We can definitely keep the Form debug info panel in the QuestionEditComponent template for further reference, yet there's no need to copy/paste it within the other form-based components' templates or anywhere else.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.59.173.242