angular-gem 1.2.14 → 1.2.15

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,607 @@
1
+ /**
2
+ * @license AngularJS v1.2.15
3
+ * (c) 2010-2014 Google, Inc. http://angularjs.org
4
+ * License: MIT
5
+ */
6
+ (function(window, angular, undefined) {'use strict';
7
+
8
+ var $resourceMinErr = angular.$$minErr('$resource');
9
+
10
+ // Helper functions and regex to lookup a dotted path on an object
11
+ // stopping at undefined/null. The path must be composed of ASCII
12
+ // identifiers (just like $parse)
13
+ var MEMBER_NAME_REGEX = /^(\.[a-zA-Z_$][0-9a-zA-Z_$]*)+$/;
14
+
15
+ function isValidDottedPath(path) {
16
+ return (path != null && path !== '' && path !== 'hasOwnProperty' &&
17
+ MEMBER_NAME_REGEX.test('.' + path));
18
+ }
19
+
20
+ function lookupDottedPath(obj, path) {
21
+ if (!isValidDottedPath(path)) {
22
+ throw $resourceMinErr('badmember', 'Dotted member path "@{0}" is invalid.', path);
23
+ }
24
+ var keys = path.split('.');
25
+ for (var i = 0, ii = keys.length; i < ii && obj !== undefined; i++) {
26
+ var key = keys[i];
27
+ obj = (obj !== null) ? obj[key] : undefined;
28
+ }
29
+ return obj;
30
+ }
31
+
32
+ /**
33
+ * Create a shallow copy of an object and clear other fields from the destination
34
+ */
35
+ function shallowClearAndCopy(src, dst) {
36
+ dst = dst || {};
37
+
38
+ angular.forEach(dst, function(value, key){
39
+ delete dst[key];
40
+ });
41
+
42
+ for (var key in src) {
43
+ if (src.hasOwnProperty(key) && !(key.charAt(0) === '$' && key.charAt(1) === '$')) {
44
+ dst[key] = src[key];
45
+ }
46
+ }
47
+
48
+ return dst;
49
+ }
50
+
51
+ /**
52
+ * @ngdoc module
53
+ * @name ngResource
54
+ * @description
55
+ *
56
+ * # ngResource
57
+ *
58
+ * The `ngResource` module provides interaction support with RESTful services
59
+ * via the $resource service.
60
+ *
61
+ *
62
+ * <div doc-module-components="ngResource"></div>
63
+ *
64
+ * See {@link ngResource.$resource `$resource`} for usage.
65
+ */
66
+
67
+ /**
68
+ * @ngdoc service
69
+ * @name $resource
70
+ * @requires $http
71
+ *
72
+ * @description
73
+ * A factory which creates a resource object that lets you interact with
74
+ * [RESTful](http://en.wikipedia.org/wiki/Representational_State_Transfer) server-side data sources.
75
+ *
76
+ * The returned resource object has action methods which provide high-level behaviors without
77
+ * the need to interact with the low level {@link ng.$http $http} service.
78
+ *
79
+ * Requires the {@link ngResource `ngResource`} module to be installed.
80
+ *
81
+ * @param {string} url A parametrized URL template with parameters prefixed by `:` as in
82
+ * `/user/:username`. If you are using a URL with a port number (e.g.
83
+ * `http://example.com:8080/api`), it will be respected.
84
+ *
85
+ * If you are using a url with a suffix, just add the suffix, like this:
86
+ * `$resource('http://example.com/resource.json')` or `$resource('http://example.com/:id.json')`
87
+ * or even `$resource('http://example.com/resource/:resource_id.:format')`
88
+ * If the parameter before the suffix is empty, :resource_id in this case, then the `/.` will be
89
+ * collapsed down to a single `.`. If you need this sequence to appear and not collapse then you
90
+ * can escape it with `/\.`.
91
+ *
92
+ * @param {Object=} paramDefaults Default values for `url` parameters. These can be overridden in
93
+ * `actions` methods. If any of the parameter value is a function, it will be executed every time
94
+ * when a param value needs to be obtained for a request (unless the param was overridden).
95
+ *
96
+ * Each key value in the parameter object is first bound to url template if present and then any
97
+ * excess keys are appended to the url search query after the `?`.
98
+ *
99
+ * Given a template `/path/:verb` and parameter `{verb:'greet', salutation:'Hello'}` results in
100
+ * URL `/path/greet?salutation=Hello`.
101
+ *
102
+ * If the parameter value is prefixed with `@` then the value of that parameter is extracted from
103
+ * the data object (useful for non-GET operations).
104
+ *
105
+ * @param {Object.<Object>=} actions Hash with declaration of custom action that should extend
106
+ * the default set of resource actions. The declaration should be created in the format of {@link
107
+ * ng.$http#usage_parameters $http.config}:
108
+ *
109
+ * {action1: {method:?, params:?, isArray:?, headers:?, ...},
110
+ * action2: {method:?, params:?, isArray:?, headers:?, ...},
111
+ * ...}
112
+ *
113
+ * Where:
114
+ *
115
+ * - **`action`** – {string} – The name of action. This name becomes the name of the method on
116
+ * your resource object.
117
+ * - **`method`** – {string} – HTTP request method. Valid methods are: `GET`, `POST`, `PUT`,
118
+ * `DELETE`, and `JSONP`.
119
+ * - **`params`** – {Object=} – Optional set of pre-bound parameters for this action. If any of
120
+ * the parameter value is a function, it will be executed every time when a param value needs to
121
+ * be obtained for a request (unless the param was overridden).
122
+ * - **`url`** – {string} – action specific `url` override. The url templating is supported just
123
+ * like for the resource-level urls.
124
+ * - **`isArray`** – {boolean=} – If true then the returned object for this action is an array,
125
+ * see `returns` section.
126
+ * - **`transformRequest`** –
127
+ * `{function(data, headersGetter)|Array.<function(data, headersGetter)>}` –
128
+ * transform function or an array of such functions. The transform function takes the http
129
+ * request body and headers and returns its transformed (typically serialized) version.
130
+ * - **`transformResponse`** –
131
+ * `{function(data, headersGetter)|Array.<function(data, headersGetter)>}` –
132
+ * transform function or an array of such functions. The transform function takes the http
133
+ * response body and headers and returns its transformed (typically deserialized) version.
134
+ * - **`cache`** – `{boolean|Cache}` – If true, a default $http cache will be used to cache the
135
+ * GET request, otherwise if a cache instance built with
136
+ * {@link ng.$cacheFactory $cacheFactory}, this cache will be used for
137
+ * caching.
138
+ * - **`timeout`** – `{number|Promise}` – timeout in milliseconds, or {@link ng.$q promise} that
139
+ * should abort the request when resolved.
140
+ * - **`withCredentials`** - `{boolean}` - whether to set the `withCredentials` flag on the
141
+ * XHR object. See
142
+ * [requests with credentials](https://developer.mozilla.org/en/http_access_control#section_5)
143
+ * for more information.
144
+ * - **`responseType`** - `{string}` - see
145
+ * [requestType](https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest#responseType).
146
+ * - **`interceptor`** - `{Object=}` - The interceptor object has two optional methods -
147
+ * `response` and `responseError`. Both `response` and `responseError` interceptors get called
148
+ * with `http response` object. See {@link ng.$http $http interceptors}.
149
+ *
150
+ * @returns {Object} A resource "class" object with methods for the default set of resource actions
151
+ * optionally extended with custom `actions`. The default set contains these actions:
152
+ * ```js
153
+ * { 'get': {method:'GET'},
154
+ * 'save': {method:'POST'},
155
+ * 'query': {method:'GET', isArray:true},
156
+ * 'remove': {method:'DELETE'},
157
+ * 'delete': {method:'DELETE'} };
158
+ * ```
159
+ *
160
+ * Calling these methods invoke an {@link ng.$http} with the specified http method,
161
+ * destination and parameters. When the data is returned from the server then the object is an
162
+ * instance of the resource class. The actions `save`, `remove` and `delete` are available on it
163
+ * as methods with the `$` prefix. This allows you to easily perform CRUD operations (create,
164
+ * read, update, delete) on server-side data like this:
165
+ * ```js
166
+ * var User = $resource('/user/:userId', {userId:'@id'});
167
+ * var user = User.get({userId:123}, function() {
168
+ * user.abc = true;
169
+ * user.$save();
170
+ * });
171
+ * ```
172
+ *
173
+ * It is important to realize that invoking a $resource object method immediately returns an
174
+ * empty reference (object or array depending on `isArray`). Once the data is returned from the
175
+ * server the existing reference is populated with the actual data. This is a useful trick since
176
+ * usually the resource is assigned to a model which is then rendered by the view. Having an empty
177
+ * object results in no rendering, once the data arrives from the server then the object is
178
+ * populated with the data and the view automatically re-renders itself showing the new data. This
179
+ * means that in most cases one never has to write a callback function for the action methods.
180
+ *
181
+ * The action methods on the class object or instance object can be invoked with the following
182
+ * parameters:
183
+ *
184
+ * - HTTP GET "class" actions: `Resource.action([parameters], [success], [error])`
185
+ * - non-GET "class" actions: `Resource.action([parameters], postData, [success], [error])`
186
+ * - non-GET instance actions: `instance.$action([parameters], [success], [error])`
187
+ *
188
+ * Success callback is called with (value, responseHeaders) arguments. Error callback is called
189
+ * with (httpResponse) argument.
190
+ *
191
+ * Class actions return empty instance (with additional properties below).
192
+ * Instance actions return promise of the action.
193
+ *
194
+ * The Resource instances and collection have these additional properties:
195
+ *
196
+ * - `$promise`: the {@link ng.$q promise} of the original server interaction that created this
197
+ * instance or collection.
198
+ *
199
+ * On success, the promise is resolved with the same resource instance or collection object,
200
+ * updated with data from server. This makes it easy to use in
201
+ * {@link ngRoute.$routeProvider resolve section of $routeProvider.when()} to defer view
202
+ * rendering until the resource(s) are loaded.
203
+ *
204
+ * On failure, the promise is resolved with the {@link ng.$http http response} object, without
205
+ * the `resource` property.
206
+ *
207
+ * - `$resolved`: `true` after first server interaction is completed (either with success or
208
+ * rejection), `false` before that. Knowing if the Resource has been resolved is useful in
209
+ * data-binding.
210
+ *
211
+ * @example
212
+ *
213
+ * # Credit card resource
214
+ *
215
+ * ```js
216
+ // Define CreditCard class
217
+ var CreditCard = $resource('/user/:userId/card/:cardId',
218
+ {userId:123, cardId:'@id'}, {
219
+ charge: {method:'POST', params:{charge:true}}
220
+ });
221
+
222
+ // We can retrieve a collection from the server
223
+ var cards = CreditCard.query(function() {
224
+ // GET: /user/123/card
225
+ // server returns: [ {id:456, number:'1234', name:'Smith'} ];
226
+
227
+ var card = cards[0];
228
+ // each item is an instance of CreditCard
229
+ expect(card instanceof CreditCard).toEqual(true);
230
+ card.name = "J. Smith";
231
+ // non GET methods are mapped onto the instances
232
+ card.$save();
233
+ // POST: /user/123/card/456 {id:456, number:'1234', name:'J. Smith'}
234
+ // server returns: {id:456, number:'1234', name: 'J. Smith'};
235
+
236
+ // our custom method is mapped as well.
237
+ card.$charge({amount:9.99});
238
+ // POST: /user/123/card/456?amount=9.99&charge=true {id:456, number:'1234', name:'J. Smith'}
239
+ });
240
+
241
+ // we can create an instance as well
242
+ var newCard = new CreditCard({number:'0123'});
243
+ newCard.name = "Mike Smith";
244
+ newCard.$save();
245
+ // POST: /user/123/card {number:'0123', name:'Mike Smith'}
246
+ // server returns: {id:789, number:'0123', name: 'Mike Smith'};
247
+ expect(newCard.id).toEqual(789);
248
+ * ```
249
+ *
250
+ * The object returned from this function execution is a resource "class" which has "static" method
251
+ * for each action in the definition.
252
+ *
253
+ * Calling these methods invoke `$http` on the `url` template with the given `method`, `params` and
254
+ * `headers`.
255
+ * When the data is returned from the server then the object is an instance of the resource type and
256
+ * all of the non-GET methods are available with `$` prefix. This allows you to easily support CRUD
257
+ * operations (create, read, update, delete) on server-side data.
258
+
259
+ ```js
260
+ var User = $resource('/user/:userId', {userId:'@id'});
261
+ User.get({userId:123}, function(user) {
262
+ user.abc = true;
263
+ user.$save();
264
+ });
265
+ ```
266
+ *
267
+ * It's worth noting that the success callback for `get`, `query` and other methods gets passed
268
+ * in the response that came from the server as well as $http header getter function, so one
269
+ * could rewrite the above example and get access to http headers as:
270
+ *
271
+ ```js
272
+ var User = $resource('/user/:userId', {userId:'@id'});
273
+ User.get({userId:123}, function(u, getResponseHeaders){
274
+ u.abc = true;
275
+ u.$save(function(u, putResponseHeaders) {
276
+ //u => saved user object
277
+ //putResponseHeaders => $http header getter
278
+ });
279
+ });
280
+ ```
281
+ *
282
+ * You can also access the raw `$http` promise via the `$promise` property on the object returned
283
+ *
284
+ ```
285
+ var User = $resource('/user/:userId', {userId:'@id'});
286
+ User.get({userId:123})
287
+ .$promise.then(function(user) {
288
+ $scope.user = user;
289
+ });
290
+ ```
291
+
292
+ * # Creating a custom 'PUT' request
293
+ * In this example we create a custom method on our resource to make a PUT request
294
+ * ```js
295
+ * var app = angular.module('app', ['ngResource', 'ngRoute']);
296
+ *
297
+ * // Some APIs expect a PUT request in the format URL/object/ID
298
+ * // Here we are creating an 'update' method
299
+ * app.factory('Notes', ['$resource', function($resource) {
300
+ * return $resource('/notes/:id', null,
301
+ * {
302
+ * 'update': { method:'PUT' }
303
+ * });
304
+ * }]);
305
+ *
306
+ * // In our controller we get the ID from the URL using ngRoute and $routeParams
307
+ * // We pass in $routeParams and our Notes factory along with $scope
308
+ * app.controller('NotesCtrl', ['$scope', '$routeParams', 'Notes',
309
+ function($scope, $routeParams, Notes) {
310
+ * // First get a note object from the factory
311
+ * var note = Notes.get({ id:$routeParams.id });
312
+ * $id = note.id;
313
+ *
314
+ * // Now call update passing in the ID first then the object you are updating
315
+ * Notes.update({ id:$id }, note);
316
+ *
317
+ * // This will PUT /notes/ID with the note object in the request payload
318
+ * }]);
319
+ * ```
320
+ */
321
+ angular.module('ngResource', ['ng']).
322
+ factory('$resource', ['$http', '$q', function($http, $q) {
323
+
324
+ var DEFAULT_ACTIONS = {
325
+ 'get': {method:'GET'},
326
+ 'save': {method:'POST'},
327
+ 'query': {method:'GET', isArray:true},
328
+ 'remove': {method:'DELETE'},
329
+ 'delete': {method:'DELETE'}
330
+ };
331
+ var noop = angular.noop,
332
+ forEach = angular.forEach,
333
+ extend = angular.extend,
334
+ copy = angular.copy,
335
+ isFunction = angular.isFunction;
336
+
337
+ /**
338
+ * We need our custom method because encodeURIComponent is too aggressive and doesn't follow
339
+ * http://www.ietf.org/rfc/rfc3986.txt with regards to the character set (pchar) allowed in path
340
+ * segments:
341
+ * segment = *pchar
342
+ * pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
343
+ * pct-encoded = "%" HEXDIG HEXDIG
344
+ * unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
345
+ * sub-delims = "!" / "$" / "&" / "'" / "(" / ")"
346
+ * / "*" / "+" / "," / ";" / "="
347
+ */
348
+ function encodeUriSegment(val) {
349
+ return encodeUriQuery(val, true).
350
+ replace(/%26/gi, '&').
351
+ replace(/%3D/gi, '=').
352
+ replace(/%2B/gi, '+');
353
+ }
354
+
355
+
356
+ /**
357
+ * This method is intended for encoding *key* or *value* parts of query component. We need a
358
+ * custom method because encodeURIComponent is too aggressive and encodes stuff that doesn't
359
+ * have to be encoded per http://tools.ietf.org/html/rfc3986:
360
+ * query = *( pchar / "/" / "?" )
361
+ * pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
362
+ * unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
363
+ * pct-encoded = "%" HEXDIG HEXDIG
364
+ * sub-delims = "!" / "$" / "&" / "'" / "(" / ")"
365
+ * / "*" / "+" / "," / ";" / "="
366
+ */
367
+ function encodeUriQuery(val, pctEncodeSpaces) {
368
+ return encodeURIComponent(val).
369
+ replace(/%40/gi, '@').
370
+ replace(/%3A/gi, ':').
371
+ replace(/%24/g, '$').
372
+ replace(/%2C/gi, ',').
373
+ replace(/%20/g, (pctEncodeSpaces ? '%20' : '+'));
374
+ }
375
+
376
+ function Route(template, defaults) {
377
+ this.template = template;
378
+ this.defaults = defaults || {};
379
+ this.urlParams = {};
380
+ }
381
+
382
+ Route.prototype = {
383
+ setUrlParams: function(config, params, actionUrl) {
384
+ var self = this,
385
+ url = actionUrl || self.template,
386
+ val,
387
+ encodedVal;
388
+
389
+ var urlParams = self.urlParams = {};
390
+ forEach(url.split(/\W/), function(param){
391
+ if (param === 'hasOwnProperty') {
392
+ throw $resourceMinErr('badname', "hasOwnProperty is not a valid parameter name.");
393
+ }
394
+ if (!(new RegExp("^\\d+$").test(param)) && param &&
395
+ (new RegExp("(^|[^\\\\]):" + param + "(\\W|$)").test(url))) {
396
+ urlParams[param] = true;
397
+ }
398
+ });
399
+ url = url.replace(/\\:/g, ':');
400
+
401
+ params = params || {};
402
+ forEach(self.urlParams, function(_, urlParam){
403
+ val = params.hasOwnProperty(urlParam) ? params[urlParam] : self.defaults[urlParam];
404
+ if (angular.isDefined(val) && val !== null) {
405
+ encodedVal = encodeUriSegment(val);
406
+ url = url.replace(new RegExp(":" + urlParam + "(\\W|$)", "g"), function(match, p1) {
407
+ return encodedVal + p1;
408
+ });
409
+ } else {
410
+ url = url.replace(new RegExp("(\/?):" + urlParam + "(\\W|$)", "g"), function(match,
411
+ leadingSlashes, tail) {
412
+ if (tail.charAt(0) == '/') {
413
+ return tail;
414
+ } else {
415
+ return leadingSlashes + tail;
416
+ }
417
+ });
418
+ }
419
+ });
420
+
421
+ // strip trailing slashes and set the url
422
+ url = url.replace(/\/+$/, '') || '/';
423
+ // then replace collapse `/.` if found in the last URL path segment before the query
424
+ // E.g. `http://url.com/id./format?q=x` becomes `http://url.com/id.format?q=x`
425
+ url = url.replace(/\/\.(?=\w+($|\?))/, '.');
426
+ // replace escaped `/\.` with `/.`
427
+ config.url = url.replace(/\/\\\./, '/.');
428
+
429
+
430
+ // set params - delegate param encoding to $http
431
+ forEach(params, function(value, key){
432
+ if (!self.urlParams[key]) {
433
+ config.params = config.params || {};
434
+ config.params[key] = value;
435
+ }
436
+ });
437
+ }
438
+ };
439
+
440
+
441
+ function resourceFactory(url, paramDefaults, actions) {
442
+ var route = new Route(url);
443
+
444
+ actions = extend({}, DEFAULT_ACTIONS, actions);
445
+
446
+ function extractParams(data, actionParams){
447
+ var ids = {};
448
+ actionParams = extend({}, paramDefaults, actionParams);
449
+ forEach(actionParams, function(value, key){
450
+ if (isFunction(value)) { value = value(); }
451
+ ids[key] = value && value.charAt && value.charAt(0) == '@' ?
452
+ lookupDottedPath(data, value.substr(1)) : value;
453
+ });
454
+ return ids;
455
+ }
456
+
457
+ function defaultResponseInterceptor(response) {
458
+ return response.resource;
459
+ }
460
+
461
+ function Resource(value){
462
+ shallowClearAndCopy(value || {}, this);
463
+ }
464
+
465
+ forEach(actions, function(action, name) {
466
+ var hasBody = /^(POST|PUT|PATCH)$/i.test(action.method);
467
+
468
+ Resource[name] = function(a1, a2, a3, a4) {
469
+ var params = {}, data, success, error;
470
+
471
+ /* jshint -W086 */ /* (purposefully fall through case statements) */
472
+ switch(arguments.length) {
473
+ case 4:
474
+ error = a4;
475
+ success = a3;
476
+ //fallthrough
477
+ case 3:
478
+ case 2:
479
+ if (isFunction(a2)) {
480
+ if (isFunction(a1)) {
481
+ success = a1;
482
+ error = a2;
483
+ break;
484
+ }
485
+
486
+ success = a2;
487
+ error = a3;
488
+ //fallthrough
489
+ } else {
490
+ params = a1;
491
+ data = a2;
492
+ success = a3;
493
+ break;
494
+ }
495
+ case 1:
496
+ if (isFunction(a1)) success = a1;
497
+ else if (hasBody) data = a1;
498
+ else params = a1;
499
+ break;
500
+ case 0: break;
501
+ default:
502
+ throw $resourceMinErr('badargs',
503
+ "Expected up to 4 arguments [params, data, success, error], got {0} arguments",
504
+ arguments.length);
505
+ }
506
+ /* jshint +W086 */ /* (purposefully fall through case statements) */
507
+
508
+ var isInstanceCall = this instanceof Resource;
509
+ var value = isInstanceCall ? data : (action.isArray ? [] : new Resource(data));
510
+ var httpConfig = {};
511
+ var responseInterceptor = action.interceptor && action.interceptor.response ||
512
+ defaultResponseInterceptor;
513
+ var responseErrorInterceptor = action.interceptor && action.interceptor.responseError ||
514
+ undefined;
515
+
516
+ forEach(action, function(value, key) {
517
+ if (key != 'params' && key != 'isArray' && key != 'interceptor') {
518
+ httpConfig[key] = copy(value);
519
+ }
520
+ });
521
+
522
+ if (hasBody) httpConfig.data = data;
523
+ route.setUrlParams(httpConfig,
524
+ extend({}, extractParams(data, action.params || {}), params),
525
+ action.url);
526
+
527
+ var promise = $http(httpConfig).then(function(response) {
528
+ var data = response.data,
529
+ promise = value.$promise;
530
+
531
+ if (data) {
532
+ // Need to convert action.isArray to boolean in case it is undefined
533
+ // jshint -W018
534
+ if (angular.isArray(data) !== (!!action.isArray)) {
535
+ throw $resourceMinErr('badcfg', 'Error in resource configuration. Expected ' +
536
+ 'response to contain an {0} but got an {1}',
537
+ action.isArray?'array':'object', angular.isArray(data)?'array':'object');
538
+ }
539
+ // jshint +W018
540
+ if (action.isArray) {
541
+ value.length = 0;
542
+ forEach(data, function(item) {
543
+ value.push(new Resource(item));
544
+ });
545
+ } else {
546
+ shallowClearAndCopy(data, value);
547
+ value.$promise = promise;
548
+ }
549
+ }
550
+
551
+ value.$resolved = true;
552
+
553
+ response.resource = value;
554
+
555
+ return response;
556
+ }, function(response) {
557
+ value.$resolved = true;
558
+
559
+ (error||noop)(response);
560
+
561
+ return $q.reject(response);
562
+ });
563
+
564
+ promise = promise.then(
565
+ function(response) {
566
+ var value = responseInterceptor(response);
567
+ (success||noop)(value, response.headers);
568
+ return value;
569
+ },
570
+ responseErrorInterceptor);
571
+
572
+ if (!isInstanceCall) {
573
+ // we are creating instance / collection
574
+ // - set the initial promise
575
+ // - return the instance / collection
576
+ value.$promise = promise;
577
+ value.$resolved = false;
578
+
579
+ return value;
580
+ }
581
+
582
+ // instance call
583
+ return promise;
584
+ };
585
+
586
+
587
+ Resource.prototype['$' + name] = function(params, success, error) {
588
+ if (isFunction(params)) {
589
+ error = success; success = params; params = {};
590
+ }
591
+ var result = Resource[name].call(this, params, this, success, error);
592
+ return result.$promise || result;
593
+ };
594
+ });
595
+
596
+ Resource.bind = function(additionalParamDefaults){
597
+ return resourceFactory(url, extend({}, paramDefaults, additionalParamDefaults), actions);
598
+ };
599
+
600
+ return Resource;
601
+ }
602
+
603
+ return resourceFactory;
604
+ }]);
605
+
606
+
607
+ })(window, window.angular);