I am trying to create a search function which uses text input to search for a corporation using a government http api (https://github.com/usagov/Corporate-Consumer-Contact-API-Documentation).
I have an html page called contact-list.component.html which has a button element on it that, when clicked, calls a function which exists in a component file (contact-list.component.ts). The function should use the string passed in to search using a service I am calling to find the corporation and output the results to an array I can bind to a table.
contact-list.component.html
<div class='row'>
<div class='col-md-2'>Enter Corporation Name:
</div>
<div class="col-md-4">
<input type="text"
[(ngModel)] = 'searchString'/>
<div><button class='btn btn-primary' ng-click="ContactListComponent.getResults(searchString)">Search</button>
</div>
</div>
</div>
<div class='row'>
contact-list.component.ts
getResults(_searchString: string): any{
this._contactService.getContacts(this._searchString)
.subscribe(contacts => this.contacts = contacts,
error => this.errorMessage = <any>error);
}
The problem is, when I input text and click the button, the console does not show any output and I do not appear to get any results back. In fact, when I replace the code in the getResults() method with
console.log("foo");
nothing displays in the console when I press F12. Any ideas on what I am missing?