Adding Angular search to our search page
In this section, we are going to convert the search to be Angular-based. What this means is that when the users will type in a word to search, they will then press Search and instead of reloading the page, we will do a request using Ajax and take the response of this request. I am not doing it because they type, due to API limitations at Marvel, but you could do this.
I need to also consider pagination later on and other odds and ends later on to this API.
Getting ready
It would be good to setup Angular as I did in the preceding recipe so that you are ready to start updating the MainController
and your custom js file.
How to do it…
First, we set up
MainController
to look like this:I will create the
searchFor
method, and then define it in myvm
area.Tip
Placing bindable members at the top makes it easy to read and helps you to instantly identify which members of the controller can be bound and used in the View—John Papa Guide
Then, I add
disableSearch
so...