Fields and fields and more fields. I want to make the form-filling process as quick and painless as possible, so I’m trying to implement auto-save. Update (March 19th, 2014) I’ve done quite a bit more auto-saving on my current project and I’ve updated my post with some slightly better methods. First Attempt My first attempt at an auto-save solution (while still being very new to Angular) was a directive that, based on the type of element, waited for either a change or blur event to occur and communicated to the controller (via a service) that it was time to save the model.
<input type='text' ng-model='myModel.field1' auto-save /><select ng-model='myModel.field2' auto-save >... A simpler version of this method might look something like this: Build a RESTful API Using Node and Express 4. # Express Router and Routes We will use an instance of the Express Router to handle all of our routes.
Here is an overview of the routes we will require, what they will do, and the HTTP Verb used to access it. This will cover the basic routes needed for an API. This also keeps to a good format where we have kept the actions we need to execute (GET, POST, PUT, and DELETE) as HTTP verbs. # Route Middleware We’ve already defined our first route and seen it in action. Let’s say that we wanted something to happen every time a request was sent to our API. All we needed to do to declare that middleware was to use router.use(function()). We are sending back information as JSON data. We will also add next() to indicate to our application that it should continue to the other routes. Middleware Uses Using middleware like this can be very powerful. Testing Our Middleware With middleware, we can do awesome things to requests coming into our API.
. # Creating the Basic Routes Creating a Bear POST /api/bears.