Skip to content

Instantly share code, notes, and snippets.

@paul-english
Created October 17, 2013 18:16
Show Gist options
  • Save paul-english/7029656 to your computer and use it in GitHub Desktop.
Save paul-english/7029656 to your computer and use it in GitHub Desktop.
Angular resource doesn't bind urlParameters for
api = $resource('http://127.0.0.1/api/v1/:type/:id',
{
type: '@type'
id: '@id'
},
{
get: {method: 'GET'}
post: {method: 'POST', headers: {'Content-Type': 'application/json'}}
del: {method: 'DELETE', headers: {'Content-Type': 'application/json'}}
create: {method: 'POST', headers: {'Content-Type': 'application/json'}}
update: {method: 'PUT', headers: {'Content-Type': 'application/json'}}
}
)
User = api.bind({type: 'user'})
User.get({}, (user_response)->
users = user_response.objects
user = users[0]
user.name = "John"
user.update() # This will fail, as it doesn't know the default type parameter
user.update({type: 'user'}) # This will work
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment