refactor angular code into a module

this allows us to organize out code into controllers which we can use to seperate out the logic of our app

he we introduce serveral concepts

- modules
- controllers
- dependency injection

- we use the ng-controller directive to give tell angular which controller address a part of the page
- the ng-submit directive tells angular to run a function when the submit button is pressed

we pass the $scope variable to our controllers so angular knows to add its contents to the controller's scope

notes:
 -  make sure to pay attention to what elements are inside of the element that has the ng-controller attribute. Only that element and its children will have access to the variables in its scope
now the app communcates with the backend

intergrated the ng-resource model to make api calls to our rails backend

notes:

Cross Site Request Forgery

Rails uses this token (which you can see in html meta tag named
"csrf-token" in the html of a rails app) to ensure that the user is
making a request to a url on the rails site only from the application's
web presence itself and not a malicious third party website.

You can learn more about them here
http://en.wikipedia.org/wiki/Cross-site_request_forgery

Since we are using angular's javascript to make requests to a rails api
we need to give angular that token to use in requests to the server

We do that with the 'ng-rails-csrf' gem. Which we include very similarly
to how we included the ng-resource module its

https://github.com/xrd/ng-rails-csrf

Also by default rails serves rails serves the root of a route as html
(i.e. /entries) we need to let rails know that we always want json.

We can do this one of 2 ways.

tell our $resource services calls to always call a .json route like this

        var Entry = $resource("/entries.json/:id", {id: "@id"}, {update:
        {method: "PATCH"}})

but that would become cumbersome to have to remember all of the time
with only the criptic 406 error to tell us something has gone wrong. So
because we will always want json from this app we can tell our rails
routes to server json by default like this:

          resources :entries, defaults: {format: :json}

http://stackoverflow.com/questions/23123184/completed-406-not-acceptable-error-when-attempting-angular-js-query-function#comment35380274_23129610