Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Laravel 5.x Cookbook

You're reading from  Laravel 5.x Cookbook

Product type Book
Published in Sep 2016
Publisher Packt
ISBN-13 9781786462084
Pages 402 pages
Edition 1st Edition
Languages
Authors (2):
Terry Matula Terry Matula
Profile icon Terry Matula
Alfred Nutile Alfred Nutile
Profile icon Alfred Nutile
View More author details

Table of Contents (17) Chapters

Laravel 5.x Cookbook
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
1. Setting Up and Installing Laravel 2. Using Composer Packages 3. Routing 4. Building Views and Adding Style 5. Working with Data 6. Adding Angular to Your App 7. Authentication, Security, and Subscriptions 8. Testing and Debugging Your Application 9. Adding Advanced Features to Your App 10. Deploying Your App Index

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…

  1. Return favorites into the Home Page JavaScript:

    The getUserInfo method is here:

  2. Then, make a tab area on the home page to show this resources/views/home/index.blade.php data:

  3. Then, we update the template called resources/views/home/_search.blade.php:

    We also update resources/views/home/_favorites.blade.php:

  4. Now, when users click on Favorites, they will see them (but there are none):

  5. Now, add a button to the results...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime}