I have again added to my eWorm Rails Web App in a few feature branch. This addition focuses on using an Angular front-end and rails JSON back-end to load and update data on the server on a single page.
I first tweaked my JSON back-end routes in config/routes.rb.
When I began building the one-page app, I made some changes to my rails layouts. I got rid of <% yield %> and created a new navigation partial that utilizes the Angular UI Router.
I implemented all routing in an organized fashion with Angular UI Router using states like so…
To handle checking if a user is logged in, I created some $rootScope functions in Angular.run().
Filters and sorting are really easy and powerful in Angular. In the view we have…
And in the controller we have…
Updating the list of books happens in real time! It’s pretty awesome, I tell you.
This project was challenging because Angular is quite powerful but the error messages are not always helpful. Testing my code in the browser often was essential to success. Again, this project was a unique challenge that forced me to use all of my new-found skills and a great learning experience as I move forward in my Learn Verified adventure!