Skip to content

Instantly share code, notes, and snippets.

@samelliott89
Last active August 29, 2015 14:04
Show Gist options
  • Save samelliott89/163071d9aacdd847e2b9 to your computer and use it in GitHub Desktop.
Save samelliott89/163071d9aacdd847e2b9 to your computer and use it in GitHub Desktop.
//resrouce
require 'angular'
bs = window.angular.module 'backstage'
bs.factory 'Stories', [
'$resource', 'transform', ($resource, transform) ->
resource = $resource '/api/stories/suggestions',
get:
method: 'get'
transformResponse: transform.response 'stories'
]
bs.factory 'StoryWizard', [
'$resource', 'transform', ($resource, transform) ->
resource = $resource '/api/_admin/stories/suggestions',
add:
method: 'post',
url: '/api/_admin/stories/suggestions'
transformResponse: transform.response 'stories'
update:
method: 'put',
url: '/api/_admin/stories/suggestions'
transformResponse: transform.response 'stories'
]
//controller
require 'angular'
_ = require 'underscore'
bs = window.angular.module 'backstage'
bs.controller 'StoryWizardCtrl', [
'$state', 'Stories', ($state, Stories) ->
@stories = []
return
]
//response
{
"stories": [
{
"bond": "have",
"messages": {
"vintage": [
"Secret: This is actually a hand-me-down, though it looks brand new!",
"Finally! Been eyeing this for years!"
],
"buy": [
"Love this one - I bought for myself. Jealous? You should be.",
"I'm a sucker for anything on sale."
],
"gift": [
"This one is safe from the 're-wrap for distant relatives' list.",
"Best. Present. Ever."
]
}
},
{
"bond": "want",
"messages": {
"want": [
"This needs to be at my place.",
"Hint hint. #BirthdayPresent"
]
}
},
{
"bond": "admire",
"messages": {
"admire": [
"Wow, this is amazing! #incredible",
"We #admire what we can't #have"
]
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment