Building a favorites Ajax widget in Angular
What I will cover in this section is adding the ability for a user to click on a star
next to the comic, and then it will be saved to the database, and added it as a Favorite
via a widget on the page.
This is what they will see on the search results page:
When they click on the Favorites
Tab, they see only their Favorites
and can remove them:
This way you can see and remove Favorites
. And since I am using a lot of the same layout, it should save me time.
Getting ready
See the previous recipe for setting up the model or just follow along.
How it works…
Return
favorites
into the Home Page JavaScript:The
getUserInfo
method is here:Then, make a tab area on the home page to show this
resources/views/home/index.blade.php
data:Then, we update the template called
resources/views/home/_search.blade.php
:We also update
resources/views/home/_favorites.blade.php
:Now, when users click on Favorites, they will see them (but there are none):
Now, add a button to the results...