How to set up angular js services

I'm building an app to manage an employee reward program and I figured I'd try to learn some of these new js frameworks that I hear about all the time, so I decided to check out Angular. Now I hope that someone who actually used this framework can help create a quick example for me.

Now I'm stuck on how to create complex angular models and a service to keep it in sync with the REST backend.

I'm not sure how to put it right, but .. I would like to have an employee (model?) Who has an account (different model?) And that account will have many transactions (models?) At least that how I have my database set up right now. Accounts and transaction data are like a bonus bank account that employees can earn. Employees, accounts and transactions are located in a URI like http://api.mydomain.com/employees / accounts / transaction

I already know how data binding and communication works, and I was able to use the $ http service to successfully deliver GET JSON data from my server, but it observes the change, validation and sync pattern with the backend server which alerted me.

So I would really appreciate any help to get the ball rolling :)

+3


source to share


1 answer


If you want to create a "pure" RESTful application with angular.js, for each endpoint on the backend, you create an associated model on the frontend, and you create, read, update and delete the resource at the endpoint you must use the $resource

instable plugin $http

.



Here is an article to help you get started.

+4


source







All Articles