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 ...
Get Laravel 5.x Cookbook 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.