SHARE
TWEET
Untitled
a guest
Jan 26th, 2016
47
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- #### Output
- controller before this.note
- controller after this.note
- interceptor
- ##### Controller
- angular.module('DiaryApp').controller('NoteEditController', ['Note','$routeParams', '$location', function(noteService, $routeParams, $location) {
- console.log('controller before this.note');
- this.note = noteService.get({id: $routeParams.id});
- console.log('controller after this.note');
- #### Resource
- angular.module('DiaryApp').factory('Note', ['$resource', function($resource) {
- function parseResponseDates(response) {
- var data = response.data, key, value;
- for (key in data) {
- if (!data.hasOwnProperty(key) && toString.call(data[key]) !== '[object String]') continue;
- value = Date.parse(data[key]);
- if(!isNaN(value)) data[key] = value;
- }
- console.log('interceptor');
- return response;
- }
- return $resource('/notes/:id', {id: "@id"},
- {
- 'update': {
- method:'PUT'
- },
- 'get': {
- method: 'GET',
- interceptor: {response: parseResponseDates}
- }
- });
- }]);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.
