Turning on suggestions for new issues
The reactive forms API contains a mechanism for getting notified when the value of a particular form control changes. We will use it in our application to find related issues when reporting a new one. More specifically, we will display a list of suggested issues when the user starts typing in the title form control:
- Open the
issues.service.tsfile and add the following method:getSuggestions(title: string): Issue[] { Â Â if (title.length > 3) { Â Â Â Â return this.issues.filter(issue => Â Â Â Â Â Â issue.title.indexOf(title) !== -1); Â Â } Â Â return []; }The
getSuggestionsmethod takes the title of an issue as a parameter and searches for any issues that contain the same title. The search mechanism is triggered when thetitleparameter is more than three characters long to limit results down to a reasonable amount. - Open the
issue-report.component.tsfile and add...