Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @app.config(['$httpProvider', ($httpProvider) ->
- $httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8'
- $httpProvider.defaults.transformRequest = [(data) ->
- param = (obj) ->
- query = ''
- for own name of obj
- value = obj[name]
- if value instanceof Array
- for i in [0..value.length]
- subValue = value[i]
- fullSubName = "#{name}[#{i}]"
- innerObj = {}
- innerObj[fullSubName] = subValue
- query += "#{param(innerObj)}&"
- else if value instanceof Object
- for own subName of value
- subValue = value[subName]
- fullSubName = "#{name}[#{subName}]"
- innerObj = {}
- innerObj[fullSubName] = subValue
- query += "#{param(innerObj)}&"
- else if value != undefined and value != null
- query += "#{encodeURIComponent(name)}=#{encodeURIComponent(value)}&"
- return (if query.length then query.substr(0, query.length - 1) else query)
- if angular.isObject(data) and String(data) != '[object File]' then param(data) else data
- ]
- ])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement