angular-resource
Advanced tools
Comparing version 1.3.0 to 1.3.1
/** | ||
* @license AngularJS v1.3.0 | ||
* @license AngularJS v1.3.1 | ||
* (c) 2010-2014 Google, Inc. http://angularjs.org | ||
@@ -38,3 +38,3 @@ * License: MIT | ||
angular.forEach(dst, function(value, key){ | ||
angular.forEach(dst, function(value, key) { | ||
delete dst[key]; | ||
@@ -88,3 +88,3 @@ }); | ||
* ```js | ||
app.config(['$resourceProvider', function ($resourceProvider) { | ||
app.config(['$resourceProvider', function($resourceProvider) { | ||
// Don't strip trailing slashes from calculated URLs | ||
@@ -355,3 +355,3 @@ $resourceProvider.defaults.stripTrailingSlashes = false; | ||
angular.module('ngResource', ['ng']). | ||
provider('$resource', function () { | ||
provider('$resource', function() { | ||
var provider = this; | ||
@@ -373,3 +373,3 @@ | ||
this.$get = ['$http', '$q', function ($http, $q) { | ||
this.$get = ['$http', '$q', function($http, $q) { | ||
@@ -428,3 +428,3 @@ var noop = angular.noop, | ||
Route.prototype = { | ||
setUrlParams: function (config, params, actionUrl) { | ||
setUrlParams: function(config, params, actionUrl) { | ||
var self = this, | ||
@@ -436,3 +436,3 @@ url = actionUrl || self.template, | ||
var urlParams = self.urlParams = {}; | ||
forEach(url.split(/\W/), function (param) { | ||
forEach(url.split(/\W/), function(param) { | ||
if (param === 'hasOwnProperty') { | ||
@@ -449,11 +449,11 @@ throw $resourceMinErr('badname', "hasOwnProperty is not a valid parameter name."); | ||
params = params || {}; | ||
forEach(self.urlParams, function (_, urlParam) { | ||
forEach(self.urlParams, function(_, urlParam) { | ||
val = params.hasOwnProperty(urlParam) ? params[urlParam] : self.defaults[urlParam]; | ||
if (angular.isDefined(val) && val !== null) { | ||
encodedVal = encodeUriSegment(val); | ||
url = url.replace(new RegExp(":" + urlParam + "(\\W|$)", "g"), function (match, p1) { | ||
url = url.replace(new RegExp(":" + urlParam + "(\\W|$)", "g"), function(match, p1) { | ||
return encodedVal + p1; | ||
}); | ||
} else { | ||
url = url.replace(new RegExp("(\/?):" + urlParam + "(\\W|$)", "g"), function (match, | ||
url = url.replace(new RegExp("(\/?):" + urlParam + "(\\W|$)", "g"), function(match, | ||
leadingSlashes, tail) { | ||
@@ -482,3 +482,3 @@ if (tail.charAt(0) == '/') { | ||
// set params - delegate param encoding to $http | ||
forEach(params, function (value, key) { | ||
forEach(params, function(value, key) { | ||
if (!self.urlParams[key]) { | ||
@@ -501,3 +501,3 @@ config.params = config.params || {}; | ||
actionParams = extend({}, paramDefaults, actionParams); | ||
forEach(actionParams, function (value, key) { | ||
forEach(actionParams, function(value, key) { | ||
if (isFunction(value)) { value = value(); } | ||
@@ -518,3 +518,3 @@ ids[key] = value && value.charAt && value.charAt(0) == '@' ? | ||
Resource.prototype.toJSON = function () { | ||
Resource.prototype.toJSON = function() { | ||
var data = extend({}, this); | ||
@@ -526,6 +526,6 @@ delete data.$promise; | ||
forEach(actions, function (action, name) { | ||
forEach(actions, function(action, name) { | ||
var hasBody = /^(POST|PUT|PATCH)$/i.test(action.method); | ||
Resource[name] = function (a1, a2, a3, a4) { | ||
Resource[name] = function(a1, a2, a3, a4) { | ||
var params = {}, data, success, error; | ||
@@ -578,3 +578,3 @@ | ||
forEach(action, function (value, key) { | ||
forEach(action, function(value, key) { | ||
if (key != 'params' && key != 'isArray' && key != 'interceptor') { | ||
@@ -590,3 +590,3 @@ httpConfig[key] = copy(value); | ||
var promise = $http(httpConfig).then(function (response) { | ||
var promise = $http(httpConfig).then(function(response) { | ||
var data = response.data, | ||
@@ -607,3 +607,3 @@ promise = value.$promise; | ||
value.length = 0; | ||
forEach(data, function (item) { | ||
forEach(data, function(item) { | ||
if (typeof item === "object") { | ||
@@ -629,3 +629,3 @@ value.push(new Resource(item)); | ||
return response; | ||
}, function (response) { | ||
}, function(response) { | ||
value.$resolved = true; | ||
@@ -639,3 +639,3 @@ | ||
promise = promise.then( | ||
function (response) { | ||
function(response) { | ||
var value = responseInterceptor(response); | ||
@@ -662,3 +662,3 @@ (success || noop)(value, response.headers); | ||
Resource.prototype['$' + name] = function (params, success, error) { | ||
Resource.prototype['$' + name] = function(params, success, error) { | ||
if (isFunction(params)) { | ||
@@ -672,3 +672,3 @@ error = success; success = params; params = {}; | ||
Resource.bind = function (additionalParamDefaults) { | ||
Resource.bind = function(additionalParamDefaults) { | ||
return resourceFactory(url, extend({}, paramDefaults, additionalParamDefaults), actions); | ||
@@ -675,0 +675,0 @@ }; |
/* | ||
AngularJS v1.3.0 | ||
AngularJS v1.3.1 | ||
(c) 2010-2014 Google, Inc. http://angularjs.org | ||
@@ -4,0 +4,0 @@ License: MIT |
{ | ||
"name": "angular-resource", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"main": "./angular-resource.js", | ||
"ignore": [], | ||
"dependencies": { | ||
"angular": "1.3.0" | ||
"angular": "1.3.1" | ||
} | ||
} |
{ | ||
"name": "angular-resource", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"description": "AngularJS module for interacting with RESTful server-side data sources", | ||
@@ -5,0 +5,0 @@ "main": "angular-resource.js", |
@@ -1,4 +0,4 @@ | ||
# bower-angular-resource | ||
# packaged angular-resource | ||
This repo is for distribution on `bower`. The source for this module is in the | ||
This repo is for distribution on `npm` and `bower`. The source for this module is in the | ||
[main AngularJS repo](https://github.com/angular/angular.js/tree/master/src/ngResource). | ||
@@ -9,5 +9,28 @@ Please file issues and pull requests against that repo. | ||
Install with `bower`: | ||
You can install this package either with `npm` or with `bower`. | ||
### npm | ||
```shell | ||
npm install angular-resource | ||
``` | ||
Add a `<script>` to your `index.html`: | ||
```html | ||
<script src="/node_modules/angular-resource/angular-resource.js"></script> | ||
``` | ||
Then add `ngResource` as a dependency for your app: | ||
```javascript | ||
angular.module('myApp', ['ngResource']); | ||
``` | ||
Note that this package is not in CommonJS format, so doing `require('angular-resource')` will | ||
return `undefined`. | ||
### bower | ||
```shell | ||
bower install angular-resource | ||
@@ -22,3 +45,3 @@ ``` | ||
And add `ngResource` as a dependency for your app: | ||
Then add `ngResource` as a dependency for your app: | ||
@@ -25,0 +48,0 @@ ```javascript |
Sorry, the diff of this file is not supported yet
42773
634
78