diff options
| author | Teddy Wing | 2015-01-24 09:41:57 -0500 | 
|---|---|---|
| committer | Teddy Wing | 2015-01-24 09:41:57 -0500 | 
| commit | c764e3b3964e137038b964c44b0b736828478868 (patch) | |
| tree | 9c26044cfbedf6c8b5885a9a130540b456dc4b57 /app/assets/javascripts/services | |
| parent | ac4ca71de63bc3ab75b520cfe382040926079982 (diff) | |
| download | Notes-angular-demo-c764e3b3964e137038b964c44b0b736828478868.tar.bz2 | |
Create initial Notes Angular app
Lists all notes and populates content section with the body of a note
when one is clicked.
Diffstat (limited to 'app/assets/javascripts/services')
| -rw-r--r-- | app/assets/javascripts/services/notes.js | 29 | 
1 files changed, 29 insertions, 0 deletions
diff --git a/app/assets/javascripts/services/notes.js b/app/assets/javascripts/services/notes.js new file mode 100644 index 0000000..b1b4e90 --- /dev/null +++ b/app/assets/javascripts/services/notes.js @@ -0,0 +1,29 @@ +angular +	.module('nt.NoteService', ['ngResource']) +	.factory('NoteService', [ +		'$resource', +		function($resource) { +			var Note = $resource('/notes/:id.json', { id: '@id' }); +			 +			return { +				notes: [], +				current_note: null, +				 +				get_notes: function() { +					this.notes = Note.query(); +				}, +				 +				get_note: function(note) { +					this.current_note = Note.get({ id: note.id }); +				}, +				 +				save: function() { +					Note.save({ +						id: this.current_note.id, +						title: this.current_note.title, +						body: this.current_note.body +					}); +				} +			}; +		} +	]);  | 
