angular-rails-engine 1.2.0.0 → 1.2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/README.md +1 -1
- data/app/assets/javascripts/angular/angular-animate.js +837 -288
- data/app/assets/javascripts/angular/angular-animate.min.js +17 -10
- data/app/assets/javascripts/angular/angular-animate.min.js.map +8 -0
- data/app/assets/javascripts/angular/angular-cookies.js +20 -2
- data/app/assets/javascripts/angular/angular-cookies.min.js +2 -4
- data/app/assets/javascripts/angular/angular-cookies.min.js.map +8 -0
- data/app/assets/javascripts/angular/angular-loader.js +31 -19
- data/app/assets/javascripts/angular/angular-loader.min.js +4 -6
- data/app/assets/javascripts/angular/angular-loader.min.js.map +8 -0
- data/app/assets/javascripts/angular/angular-mocks.js +263 -85
- data/app/assets/javascripts/angular/angular-resource.js +125 -95
- data/app/assets/javascripts/angular/angular-resource.min.js +8 -10
- data/app/assets/javascripts/angular/angular-resource.min.js.map +8 -0
- data/app/assets/javascripts/angular/angular-route.js +161 -141
- data/app/assets/javascripts/angular/angular-route.min.js +10 -11
- data/app/assets/javascripts/angular/angular-route.min.js.map +8 -0
- data/app/assets/javascripts/angular/angular-sanitize.js +135 -116
- data/app/assets/javascripts/angular/angular-sanitize.min.js +10 -11
- data/app/assets/javascripts/angular/angular-sanitize.min.js.map +8 -0
- data/app/assets/javascripts/angular/angular-scenario.js +13909 -11404
- data/app/assets/javascripts/angular/angular-touch.js +47 -20
- data/app/assets/javascripts/angular/angular-touch.min.js +9 -10
- data/app/assets/javascripts/angular/angular-touch.min.js.map +8 -0
- data/app/assets/javascripts/angular/angular.js +4407 -2278
- data/app/assets/javascripts/angular/angular.min.js +196 -181
- data/app/assets/javascripts/angular/angular.min.js.map +8 -0
- data/app/assets/stylesheets/angular-csp.css +24 -0
- data/lib/angular-rails-engine.rb +1 -1
- data/lib/angular-rails-engine/version.rb +1 -1
- metadata +11 -2
- metadata.gz.sig +0 -0
@@ -1,5 +1,5 @@
|
|
1
1
|
/**
|
2
|
-
* @license AngularJS v1.2.
|
2
|
+
* @license AngularJS v1.2.0
|
3
3
|
* (c) 2010-2012 Google, Inc. http://angularjs.org
|
4
4
|
* License: MIT
|
5
5
|
*/
|
@@ -11,6 +11,17 @@ var $resourceMinErr = angular.$$minErr('$resource');
|
|
11
11
|
* @ngdoc overview
|
12
12
|
* @name ngResource
|
13
13
|
* @description
|
14
|
+
*
|
15
|
+
* # ngResource
|
16
|
+
*
|
17
|
+
* The `ngResource` module provides interaction support with RESTful services
|
18
|
+
* via the $resource service.
|
19
|
+
*
|
20
|
+
* {@installModule resource}
|
21
|
+
*
|
22
|
+
* <div doc-module-components="ngResource"></div>
|
23
|
+
*
|
24
|
+
* See {@link ngResource.$resource `$resource`} for usage.
|
14
25
|
*/
|
15
26
|
|
16
27
|
/**
|
@@ -25,23 +36,14 @@ var $resourceMinErr = angular.$$minErr('$resource');
|
|
25
36
|
* The returned resource object has action methods which provide high-level behaviors without
|
26
37
|
* the need to interact with the low level {@link ng.$http $http} service.
|
27
38
|
*
|
28
|
-
*
|
29
|
-
* To use $resource make sure you have included the `angular-resource.js` that comes in Angular
|
30
|
-
* package. You can also find this file on Google CDN, bower as well as at
|
31
|
-
* {@link http://code.angularjs.org/ code.angularjs.org}.
|
32
|
-
*
|
33
|
-
* Finally load the module in your application:
|
34
|
-
*
|
35
|
-
* angular.module('app', ['ngResource']);
|
36
|
-
*
|
37
|
-
* and you are ready to get started!
|
39
|
+
* Requires the {@link ngResource `ngResource`} module to be installed.
|
38
40
|
*
|
39
41
|
* @param {string} url A parametrized URL template with parameters prefixed by `:` as in
|
40
42
|
* `/user/:username`. If you are using a URL with a port number (e.g.
|
41
43
|
* `http://example.com:8080/api`), it will be respected.
|
42
44
|
*
|
43
45
|
* If you are using a url with a suffix, just add the suffix, like this:
|
44
|
-
* `$resource('http://example.com/resource.json')` or `$resource('http://example.com/:id.json')
|
46
|
+
* `$resource('http://example.com/resource.json')` or `$resource('http://example.com/:id.json')`
|
45
47
|
* or even `$resource('http://example.com/resource/:resource_id.:format')`
|
46
48
|
* If the parameter before the suffix is empty, :resource_id in this case, then the `/.` will be
|
47
49
|
* collapsed down to a single `.`. If you need this sequence to appear and not collapse then you
|
@@ -62,7 +64,7 @@ var $resourceMinErr = angular.$$minErr('$resource');
|
|
62
64
|
*
|
63
65
|
* @param {Object.<Object>=} actions Hash with declaration of custom action that should extend the
|
64
66
|
* default set of resource actions. The declaration should be created in the format of {@link
|
65
|
-
* ng.$http#
|
67
|
+
* ng.$http#usage_parameters $http.config}:
|
66
68
|
*
|
67
69
|
* {action1: {method:?, params:?, isArray:?, headers:?, ...},
|
68
70
|
* action2: {method:?, params:?, isArray:?, headers:?, ...},
|
@@ -70,21 +72,23 @@ var $resourceMinErr = angular.$$minErr('$resource');
|
|
70
72
|
*
|
71
73
|
* Where:
|
72
74
|
*
|
73
|
-
* - **`action`** – {string} – The name of action. This name becomes the name of the method on
|
74
|
-
* resource object.
|
75
|
-
* - **`method`** – {string} – HTTP request method. Valid methods are: `GET`, `POST`, `PUT`,
|
76
|
-
* and `JSONP`.
|
77
|
-
* - **`params`** – {Object=} – Optional set of pre-bound parameters for this action. If any of
|
78
|
-
* parameter value is a function, it will be executed every time when a param value needs to
|
79
|
-
* obtained for a request (unless the param was overridden).
|
80
|
-
* - **`url`** – {string} – action specific `url` override. The url templating is supported just
|
81
|
-
* for the resource-level urls.
|
82
|
-
* - **`isArray`** – {boolean=} – If true then the returned object for this action is an array,
|
83
|
-
* `returns` section.
|
84
|
-
* - **`transformRequest`** –
|
75
|
+
* - **`action`** – {string} – The name of action. This name becomes the name of the method on
|
76
|
+
* your resource object.
|
77
|
+
* - **`method`** – {string} – HTTP request method. Valid methods are: `GET`, `POST`, `PUT`,
|
78
|
+
* `DELETE`, and `JSONP`.
|
79
|
+
* - **`params`** – {Object=} – Optional set of pre-bound parameters for this action. If any of
|
80
|
+
* the parameter value is a function, it will be executed every time when a param value needs to
|
81
|
+
* be obtained for a request (unless the param was overridden).
|
82
|
+
* - **`url`** – {string} – action specific `url` override. The url templating is supported just
|
83
|
+
* like for the resource-level urls.
|
84
|
+
* - **`isArray`** – {boolean=} – If true then the returned object for this action is an array,
|
85
|
+
* see `returns` section.
|
86
|
+
* - **`transformRequest`** –
|
87
|
+
* `{function(data, headersGetter)|Array.<function(data, headersGetter)>}` –
|
85
88
|
* transform function or an array of such functions. The transform function takes the http
|
86
89
|
* request body and headers and returns its transformed (typically serialized) version.
|
87
|
-
* - **`transformResponse`** –
|
90
|
+
* - **`transformResponse`** –
|
91
|
+
* `{function(data, headersGetter)|Array.<function(data, headersGetter)>}` –
|
88
92
|
* transform function or an array of such functions. The transform function takes the http
|
89
93
|
* response body and headers and returns its transformed (typically deserialized) version.
|
90
94
|
* - **`cache`** – `{boolean|Cache}` – If true, a default $http cache will be used to cache the
|
@@ -93,7 +97,7 @@ var $resourceMinErr = angular.$$minErr('$resource');
|
|
93
97
|
* caching.
|
94
98
|
* - **`timeout`** – `{number|Promise}` – timeout in milliseconds, or {@link ng.$q promise} that
|
95
99
|
* should abort the request when resolved.
|
96
|
-
* - **`withCredentials`** - `{boolean}` - whether to
|
100
|
+
* - **`withCredentials`** - `{boolean}` - whether to set the `withCredentials` flag on the
|
97
101
|
* XHR object. See {@link https://developer.mozilla.org/en/http_access_control#section_5
|
98
102
|
* requests with credentials} for more information.
|
99
103
|
* - **`responseType`** - `{string}` - see {@link
|
@@ -152,14 +156,15 @@ var $resourceMinErr = angular.$$minErr('$resource');
|
|
152
156
|
*
|
153
157
|
* On success, the promise is resolved with the same resource instance or collection object,
|
154
158
|
* updated with data from server. This makes it easy to use in
|
155
|
-
* {@link ngRoute.$routeProvider resolve section of $routeProvider.when()} to defer view
|
156
|
-
* until the resource(s) are loaded.
|
159
|
+
* {@link ngRoute.$routeProvider resolve section of $routeProvider.when()} to defer view
|
160
|
+
* rendering until the resource(s) are loaded.
|
157
161
|
*
|
158
|
-
* On failure, the promise is resolved with the {@link ng.$http http response} object,
|
159
|
-
*
|
162
|
+
* On failure, the promise is resolved with the {@link ng.$http http response} object, without
|
163
|
+
* the `resource` property.
|
160
164
|
*
|
161
|
-
* - `$resolved`: `true` after first server interaction is completed (either with success or
|
162
|
-
*
|
165
|
+
* - `$resolved`: `true` after first server interaction is completed (either with success or
|
166
|
+
* rejection), `false` before that. Knowing if the Resource has been resolved is useful in
|
167
|
+
* data-binding.
|
163
168
|
*
|
164
169
|
* @example
|
165
170
|
*
|
@@ -203,7 +208,8 @@ var $resourceMinErr = angular.$$minErr('$resource');
|
|
203
208
|
* The object returned from this function execution is a resource "class" which has "static" method
|
204
209
|
* for each action in the definition.
|
205
210
|
*
|
206
|
-
* Calling these methods invoke `$http` on the `url` template with the given `method`, `params` and
|
211
|
+
* Calling these methods invoke `$http` on the `url` template with the given `method`, `params` and
|
212
|
+
* `headers`.
|
207
213
|
* When the data is returned from the server then the object is an instance of the resource type and
|
208
214
|
* all of the non-GET methods are available with `$` prefix. This allows you to easily support CRUD
|
209
215
|
* operations (create, read, update, delete) on server-side data.
|
@@ -216,7 +222,7 @@ var $resourceMinErr = angular.$$minErr('$resource');
|
|
216
222
|
});
|
217
223
|
</pre>
|
218
224
|
*
|
219
|
-
* It's worth noting that the success callback for `get`, `query` and other
|
225
|
+
* It's worth noting that the success callback for `get`, `query` and other methods gets passed
|
220
226
|
* in the response that came from the server as well as $http header getter function, so one
|
221
227
|
* could rewrite the above example and get access to http headers as:
|
222
228
|
*
|
@@ -235,48 +241,52 @@ var $resourceMinErr = angular.$$minErr('$resource');
|
|
235
241
|
|
236
242
|
Let's look at what a buzz client created with the `$resource` service looks like:
|
237
243
|
<doc:example>
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
244
|
+
<doc:source jsfiddle="false">
|
245
|
+
<script>
|
246
|
+
function BuzzController($resource) {
|
247
|
+
this.userId = 'googlebuzz';
|
248
|
+
this.Activity = $resource(
|
249
|
+
'https://www.googleapis.com/buzz/v1/activities/:userId/:visibility/:activityId/:comments',
|
250
|
+
{alt:'json', callback:'JSON_CALLBACK'},
|
251
|
+
{
|
252
|
+
get:{method:'JSONP', params:{visibility:'@self'}},
|
253
|
+
replies: {method:'JSONP', params:{visibility:'@self', comments:'@comments'}}
|
247
254
|
}
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
};
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
255
|
+
);
|
256
|
+
}
|
257
|
+
|
258
|
+
BuzzController.prototype = {
|
259
|
+
fetch: function() {
|
260
|
+
this.activities = this.Activity.get({userId:this.userId});
|
261
|
+
},
|
262
|
+
expandReplies: function(activity) {
|
263
|
+
activity.replies = this.Activity.replies({userId:this.userId, activityId:activity.id});
|
264
|
+
}
|
265
|
+
};
|
266
|
+
BuzzController.$inject = ['$resource'];
|
267
|
+
</script>
|
268
|
+
|
269
|
+
<div ng-controller="BuzzController">
|
270
|
+
<input ng-model="userId"/>
|
271
|
+
<button ng-click="fetch()">fetch</button>
|
272
|
+
<hr/>
|
273
|
+
<div ng-repeat="item in activities.data.items">
|
274
|
+
<h1 style="font-size: 15px;">
|
275
|
+
<img src="{{item.actor.thumbnailUrl}}" style="max-height:30px;max-width:30px;"/>
|
276
|
+
<a href="{{item.actor.profileUrl}}">{{item.actor.name}}</a>
|
277
|
+
<a href ng-click="expandReplies(item)" style="float: right;">Expand replies:
|
278
|
+
{{item.links.replies[0].count}}</a>
|
279
|
+
</h1>
|
280
|
+
{{item.object.content | html}}
|
281
|
+
<div ng-repeat="reply in item.replies.data.items" style="margin-left: 20px;">
|
282
|
+
<img src="{{reply.actor.thumbnailUrl}}" style="max-height:30px;max-width:30px;"/>
|
283
|
+
<a href="{{reply.actor.profileUrl}}">{{reply.actor.name}}</a>: {{reply.content | html}}
|
276
284
|
</div>
|
277
|
-
|
278
|
-
|
279
|
-
|
285
|
+
</div>
|
286
|
+
</div>
|
287
|
+
</doc:source>
|
288
|
+
<doc:scenario>
|
289
|
+
</doc:scenario>
|
280
290
|
</doc:example>
|
281
291
|
*/
|
282
292
|
angular.module('ngResource', ['ng']).
|
@@ -317,9 +327,9 @@ angular.module('ngResource', ['ng']).
|
|
317
327
|
|
318
328
|
|
319
329
|
/**
|
320
|
-
* This method is intended for encoding *key* or *value* parts of query component. We need a
|
321
|
-
* method because encodeURIComponent is too aggressive and encodes stuff that doesn't
|
322
|
-
* encoded per http://tools.ietf.org/html/rfc3986:
|
330
|
+
* This method is intended for encoding *key* or *value* parts of query component. We need a
|
331
|
+
* custom method because encodeURIComponent is too aggressive and encodes stuff that doesn't
|
332
|
+
* have to be encoded per http://tools.ietf.org/html/rfc3986:
|
323
333
|
* query = *( pchar / "/" / "?" )
|
324
334
|
* pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
|
325
335
|
* unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
|
@@ -351,8 +361,12 @@ angular.module('ngResource', ['ng']).
|
|
351
361
|
|
352
362
|
var urlParams = self.urlParams = {};
|
353
363
|
forEach(url.split(/\W/), function(param){
|
354
|
-
if (
|
355
|
-
|
364
|
+
if (param === 'hasOwnProperty') {
|
365
|
+
throw $resourceMinErr('badname', "hasOwnProperty is not a valid parameter name.");
|
366
|
+
}
|
367
|
+
if (!(new RegExp("^\\d+$").test(param)) && param &&
|
368
|
+
(new RegExp("(^|[^\\\\]):" + param + "(\\W|$)").test(url))) {
|
369
|
+
urlParams[param] = true;
|
356
370
|
}
|
357
371
|
});
|
358
372
|
url = url.replace(/\\:/g, ':');
|
@@ -395,7 +409,7 @@ angular.module('ngResource', ['ng']).
|
|
395
409
|
};
|
396
410
|
|
397
411
|
|
398
|
-
function
|
412
|
+
function resourceFactory(url, paramDefaults, actions) {
|
399
413
|
var route = new Route(url);
|
400
414
|
|
401
415
|
actions = extend({}, DEFAULT_ACTIONS, actions);
|
@@ -405,7 +419,8 @@ angular.module('ngResource', ['ng']).
|
|
405
419
|
actionParams = extend({}, paramDefaults, actionParams);
|
406
420
|
forEach(actionParams, function(value, key){
|
407
421
|
if (isFunction(value)) { value = value(); }
|
408
|
-
ids[key] = value && value.charAt && value.charAt(0) == '@' ?
|
422
|
+
ids[key] = value && value.charAt && value.charAt(0) == '@' ?
|
423
|
+
getter(data, value.substr(1)) : value;
|
409
424
|
});
|
410
425
|
return ids;
|
411
426
|
}
|
@@ -424,6 +439,7 @@ angular.module('ngResource', ['ng']).
|
|
424
439
|
Resource[name] = function(a1, a2, a3, a4) {
|
425
440
|
var params = {}, data, success, error;
|
426
441
|
|
442
|
+
/* jshint -W086 */ /* (purposefully fall through case statements) */
|
427
443
|
switch(arguments.length) {
|
428
444
|
case 4:
|
429
445
|
error = a4;
|
@@ -455,14 +471,18 @@ angular.module('ngResource', ['ng']).
|
|
455
471
|
case 0: break;
|
456
472
|
default:
|
457
473
|
throw $resourceMinErr('badargs',
|
458
|
-
"Expected up to 4 arguments [params, data, success, error], got {0} arguments",
|
474
|
+
"Expected up to 4 arguments [params, data, success, error], got {0} arguments",
|
475
|
+
arguments.length);
|
459
476
|
}
|
477
|
+
/* jshint +W086 */ /* (purposefully fall through case statements) */
|
460
478
|
|
461
479
|
var isInstanceCall = data instanceof Resource;
|
462
480
|
var value = isInstanceCall ? data : (action.isArray ? [] : new Resource(data));
|
463
481
|
var httpConfig = {};
|
464
|
-
var responseInterceptor = action.interceptor && action.interceptor.response ||
|
465
|
-
|
482
|
+
var responseInterceptor = action.interceptor && action.interceptor.response ||
|
483
|
+
defaultResponseInterceptor;
|
484
|
+
var responseErrorInterceptor = action.interceptor && action.interceptor.responseError ||
|
485
|
+
undefined;
|
466
486
|
|
467
487
|
forEach(action, function(value, key) {
|
468
488
|
if (key != 'params' && key != 'isArray' && key != 'interceptor') {
|
@@ -470,19 +490,24 @@ angular.module('ngResource', ['ng']).
|
|
470
490
|
}
|
471
491
|
});
|
472
492
|
|
473
|
-
httpConfig.data = data;
|
474
|
-
route.setUrlParams(httpConfig,
|
493
|
+
if (hasBody) httpConfig.data = data;
|
494
|
+
route.setUrlParams(httpConfig,
|
495
|
+
extend({}, extractParams(data, action.params || {}), params),
|
496
|
+
action.url);
|
475
497
|
|
476
498
|
var promise = $http(httpConfig).then(function(response) {
|
477
499
|
var data = response.data,
|
478
500
|
promise = value.$promise;
|
479
501
|
|
480
502
|
if (data) {
|
481
|
-
|
482
|
-
|
483
|
-
|
503
|
+
// Need to convert action.isArray to boolean in case it is undefined
|
504
|
+
// jshint -W018
|
505
|
+
if ( angular.isArray(data) !== (!!action.isArray) ) {
|
506
|
+
throw $resourceMinErr('badcfg', 'Error in resource configuration. Expected ' +
|
507
|
+
'response to contain an {0} but got an {1}',
|
484
508
|
action.isArray?'array':'object', angular.isArray(data)?'array':'object');
|
485
509
|
}
|
510
|
+
// jshint +W018
|
486
511
|
if (action.isArray) {
|
487
512
|
value.length = 0;
|
488
513
|
forEach(data, function(item) {
|
@@ -496,8 +521,6 @@ angular.module('ngResource', ['ng']).
|
|
496
521
|
|
497
522
|
value.$resolved = true;
|
498
523
|
|
499
|
-
(success||noop)(value, response.headers);
|
500
|
-
|
501
524
|
response.resource = value;
|
502
525
|
|
503
526
|
return response;
|
@@ -507,8 +530,15 @@ angular.module('ngResource', ['ng']).
|
|
507
530
|
(error||noop)(response);
|
508
531
|
|
509
532
|
return $q.reject(response);
|
510
|
-
})
|
533
|
+
});
|
511
534
|
|
535
|
+
promise = promise.then(
|
536
|
+
function(response) {
|
537
|
+
var value = responseInterceptor(response);
|
538
|
+
(success||noop)(value, response.headers);
|
539
|
+
return value;
|
540
|
+
},
|
541
|
+
responseErrorInterceptor);
|
512
542
|
|
513
543
|
if (!isInstanceCall) {
|
514
544
|
// we are creating instance / collection
|
@@ -535,13 +565,13 @@ angular.module('ngResource', ['ng']).
|
|
535
565
|
});
|
536
566
|
|
537
567
|
Resource.bind = function(additionalParamDefaults){
|
538
|
-
return
|
568
|
+
return resourceFactory(url, extend({}, paramDefaults, additionalParamDefaults), actions);
|
539
569
|
};
|
540
570
|
|
541
571
|
return Resource;
|
542
572
|
}
|
543
573
|
|
544
|
-
return
|
574
|
+
return resourceFactory;
|
545
575
|
}]);
|
546
576
|
|
547
577
|
|
@@ -1,14 +1,12 @@
|
|
1
1
|
/*
|
2
|
-
AngularJS v1.2.
|
2
|
+
AngularJS v1.2.0
|
3
3
|
(c) 2010-2012 Google, Inc. http://angularjs.org
|
4
4
|
License: MIT
|
5
5
|
*/
|
6
|
-
(function(H,
|
7
|
-
/^(POST|PUT|PATCH)$/i.test(
|
8
|
-
|
9
|
-
b){
|
10
|
-
b=
|
11
|
-
".");
|
12
|
-
|
13
|
-
//@ sourceMappingURL=angular-resource.min.js.map
|
14
|
-
*/
|
6
|
+
(function(H,h,C){'use strict';var x=h.$$minErr("$resource");h.module("ngResource",["ng"]).factory("$resource",["$http","$parse","$q",function(D,y,E){function n(h,k){this.template=h;this.defaults=k||{};this.urlParams={}}function t(e,k,f){function q(b,c){var d={};c=u({},k,c);r(c,function(a,c){s(a)&&(a=a());var m;a&&a.charAt&&"@"==a.charAt(0)?(m=a.substr(1),m=y(m)(b)):m=a;d[c]=m});return d}function d(b){return b.resource}function g(b){z(b||{},this)}var F=new n(e);f=u({},G,f);r(f,function(b,c){var A=
|
7
|
+
/^(POST|PUT|PATCH)$/i.test(b.method);g[c]=function(a,c,m,k){var p={},e,f,v;switch(arguments.length){case 4:v=k,f=m;case 3:case 2:if(s(c)){if(s(a)){f=a;v=c;break}f=c;v=m}else{p=a;e=c;f=m;break}case 1:s(a)?f=a:A?e=a:p=a;break;case 0:break;default:throw x("badargs",arguments.length);}var n=e instanceof g,l=n?e:b.isArray?[]:new g(e),w={},t=b.interceptor&&b.interceptor.response||d,y=b.interceptor&&b.interceptor.responseError||C;r(b,function(a,c){"params"!=c&&("isArray"!=c&&"interceptor"!=c)&&(w[c]=z(a))});
|
8
|
+
A&&(w.data=e);F.setUrlParams(w,u({},q(e,b.params||{}),p),b.url);p=D(w).then(function(c){var a=c.data,d=l.$promise;if(a){if(h.isArray(a)!==!!b.isArray)throw x("badcfg",b.isArray?"array":"object",h.isArray(a)?"array":"object");b.isArray?(l.length=0,r(a,function(a){l.push(new g(a))})):(z(a,l),l.$promise=d)}l.$resolved=!0;c.resource=l;return c},function(a){l.$resolved=!0;(v||B)(a);return E.reject(a)});p=p.then(function(a){var c=t(a);(f||B)(c,a.headers);return c},y);return n?p:(l.$promise=p,l.$resolved=
|
9
|
+
!1,l)};g.prototype["$"+c]=function(a,b,d){s(a)&&(d=b,b=a,a={});a=g[c](a,this,b,d);return a.$promise||a}});g.bind=function(b){return t(e,u({},k,b),f)};return g}var G={get:{method:"GET"},save:{method:"POST"},query:{method:"GET",isArray:!0},remove:{method:"DELETE"},"delete":{method:"DELETE"}},B=h.noop,r=h.forEach,u=h.extend,z=h.copy,s=h.isFunction;n.prototype={setUrlParams:function(e,k,f){var q=this,d=f||q.template,g,n,b=q.urlParams={};r(d.split(/\W/),function(c){if("hasOwnProperty"===c)throw x("badname");
|
10
|
+
!/^\d+$/.test(c)&&(c&&RegExp("(^|[^\\\\]):"+c+"(\\W|$)").test(d))&&(b[c]=!0)});d=d.replace(/\\:/g,":");k=k||{};r(q.urlParams,function(c,b){g=k.hasOwnProperty(b)?k[b]:q.defaults[b];h.isDefined(g)&&null!==g?(n=encodeURIComponent(g).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"%20").replace(/%26/gi,"&").replace(/%3D/gi,"=").replace(/%2B/gi,"+"),d=d.replace(RegExp(":"+b+"(\\W|$)","g"),n+"$1")):d=d.replace(RegExp("(/?):"+b+"(\\W|$)","g"),function(a,
|
11
|
+
c,b){return"/"==b.charAt(0)?b:c+b})});d=d.replace(/\/+$/,"");d=d.replace(/\/\.(?=\w+($|\?))/,".");e.url=d.replace(/\/\\\./,"/.");r(k,function(c,b){q.urlParams[b]||(e.params=e.params||{},e.params[b]=c)})}};return t}])})(window,window.angular);
|
12
|
+
//# sourceMappingURL=angular-resource.min.js.map
|
@@ -0,0 +1,8 @@
|
|
1
|
+
{
|
2
|
+
"version":3,
|
3
|
+
"file":"angular-resource.min.js",
|
4
|
+
"lineCount":11,
|
5
|
+
"mappings":"A;;;;;aAKC,SAAQ,CAACA,CAAD,CAASC,CAAT,CAAkBC,CAAlB,CAA6B,CAEtC,IAAIC,EAAkBF,CAAAG,SAAA,CAAiB,WAAjB,CA4RtBH,EAAAI,OAAA,CAAe,YAAf,CAA6B,CAAC,IAAD,CAA7B,CAAAC,QAAA,CACU,WADV,CACuB,CAAC,OAAD,CAAU,QAAV,CAAoB,IAApB,CAA0B,QAAQ,CAACC,CAAD,CAAQC,CAAR,CAAgBC,CAAhB,CAAoB,CAwDzEC,QAASA,EAAK,CAACC,CAAD,CAAWC,CAAX,CAAqB,CACjC,IAAAD,SAAA,CAAgBA,CAChB,KAAAC,SAAA,CAAgBA,CAAhB,EAA4B,EAC5B,KAAAC,UAAA,CAAiB,EAHgB,CA+DnCC,QAASA,EAAe,CAACC,CAAD,CAAMC,CAAN,CAAqBC,CAArB,CAA8B,CAKpDC,QAASA,EAAa,CAACC,CAAD,CAAOC,CAAP,CAAoB,CACxC,IAAIC,EAAM,EACVD,EAAA,CAAeE,CAAA,CAAO,EAAP,CAAWN,CAAX,CAA0BI,CAA1B,CACfG,EAAA,CAAQH,CAAR,CAAsB,QAAQ,CAACI,CAAD,CAAQC,CAAR,CAAY,CACpCC,CAAA,CAAWF,CAAX,CAAJ,GAAyBA,CAAzB,CAAiCA,CAAA,EAAjC,CACW,KAAA,CAAAA,EAAA,EAASA,CAAAG,OAAT,EAA4C,GAA5C,EAAyB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W,OAAX,CAAsBG,CAAtB,CAAiC,SAAjC,CAA4C,GAA5C,CAAZ,CAA8D,QAAQ,CAACI,CAAD;AACxEC,CADwE,CACxDC,CADwD,CAClD,CACxB,MAAsB,GAAtB,EAAIA,CAAA9D,OAAA,CAAY,CAAZ,CAAJ,CACS8D,CADT,CAGSD,CAHT,CAG0BC,CAJF,CADpB,CANmC,CAA7C,CAkBA1E,EAAA,CAAMA,CAAAkE,QAAA,CAAY,MAAZ,CAAoB,EAApB,CAGNlE,EAAA,CAAMA,CAAAkE,QAAA,CAAY,mBAAZ,CAAiC,GAAjC,CAENR,EAAA1D,IAAA,CAAaA,CAAAkE,QAAA,CAAY,QAAZ,CAAsB,IAAtB,CAIb1D,EAAA,CAAQuB,CAAR,CAAgB,QAAQ,CAACtB,CAAD,CAAQC,CAAR,CAAY,CAC7BkD,CAAA9D,UAAA,CAAeY,CAAf,CAAL,GACEgD,CAAA3B,OACA,CADgB2B,CAAA3B,OAChB,EADiC,EACjC,CAAA2B,CAAA3B,OAAA,CAAcrB,CAAd,CAAA,CAAqBD,CAFvB,CADkC,CAApC,CA9CgD,CADlC,CA2NlB,OAAOV,EAzRkE,CAAtD,CADvB,CA9RsC,CAArC,CAAA,CA4jBEd,MA5jBF,CA4jBUA,MAAAC,QA5jBV;",
|
6
|
+
"sources":["angular-resource.js"],
|
7
|
+
"names":["window","angular","undefined","$resourceMinErr","$$minErr","module","factory","$http","$parse","$q","Route","template","defaults","urlParams","resourceFactory","url","paramDefaults","actions","extractParams","data","actionParams","ids","extend","forEach","value","key","isFunction","charAt","path","obj","defaultResponseInterceptor","response","resource","Resource","copy","route","DEFAULT_ACTIONS","action","name","hasBody","test","method","a1","a2","a3","a4","params","success","error","arguments","length","isInstanceCall","isArray","httpConfig","responseInterceptor","interceptor","responseErrorInterceptor","responseError","setUrlParams","promise","then","$promise","item","push","$resolved","noop","reject","headers","prototype","result","bind","Resource.bind","additionalParamDefaults","config","actionUrl","self","val","encodedVal","split","param","RegExp","replace","_","urlParam","hasOwnProperty","isDefined","encodeURIComponent","match","leadingSlashes","tail"]
|
8
|
+
}
|
@@ -1,34 +1,24 @@
|
|
1
1
|
/**
|
2
|
-
* @license AngularJS v1.2.
|
2
|
+
* @license AngularJS v1.2.0
|
3
3
|
* (c) 2010-2012 Google, Inc. http://angularjs.org
|
4
4
|
* License: MIT
|
5
5
|
*/
|
6
6
|
(function(window, angular, undefined) {'use strict';
|
7
7
|
|
8
|
-
var copy = angular.copy,
|
9
|
-
equals = angular.equals,
|
10
|
-
extend = angular.extend,
|
11
|
-
forEach = angular.forEach,
|
12
|
-
isDefined = angular.isDefined,
|
13
|
-
isFunction = angular.isFunction,
|
14
|
-
isString = angular.isString,
|
15
|
-
jqLite = angular.element,
|
16
|
-
noop = angular.noop,
|
17
|
-
toJson = angular.toJson;
|
18
|
-
|
19
|
-
|
20
|
-
function inherit(parent, extra) {
|
21
|
-
return extend(new (extend(function() {}, {prototype:parent}))(), extra);
|
22
|
-
}
|
23
|
-
|
24
8
|
/**
|
25
9
|
* @ngdoc overview
|
26
10
|
* @name ngRoute
|
27
11
|
* @description
|
28
12
|
*
|
29
|
-
*
|
13
|
+
* # ngRoute
|
14
|
+
*
|
15
|
+
* The `ngRoute` module provides routing and deeplinking services and directives for angular apps.
|
16
|
+
*
|
17
|
+
* {@installModule route}
|
18
|
+
*
|
19
|
+
* <div doc-module-components="ngRoute"></div>
|
30
20
|
*/
|
31
|
-
|
21
|
+
/* global -ngRouteModule */
|
32
22
|
var ngRouteModule = angular.module('ngRoute', ['ng']).
|
33
23
|
provider('$route', $RouteProvider);
|
34
24
|
|
@@ -40,8 +30,14 @@ var ngRouteModule = angular.module('ngRoute', ['ng']).
|
|
40
30
|
* @description
|
41
31
|
*
|
42
32
|
* Used for configuring routes. See {@link ngRoute.$route $route} for an example.
|
33
|
+
*
|
34
|
+
* Requires the {@link ngRoute `ngRoute`} module to be installed.
|
43
35
|
*/
|
44
36
|
function $RouteProvider(){
|
37
|
+
function inherit(parent, extra) {
|
38
|
+
return angular.extend(new (angular.extend(function() {}, {prototype:parent}))(), extra);
|
39
|
+
}
|
40
|
+
|
45
41
|
var routes = {};
|
46
42
|
|
47
43
|
/**
|
@@ -57,8 +53,8 @@ function $RouteProvider(){
|
|
57
53
|
* * `path` can contain named groups starting with a colon (`:name`). All characters up
|
58
54
|
* to the next slash are matched and stored in `$routeParams` under the given `name`
|
59
55
|
* when the route matches.
|
60
|
-
* * `path` can contain named groups starting with a colon and ending with a star (`:name*`).
|
61
|
-
* All characters are eagerly stored in `$routeParams` under the given `name`
|
56
|
+
* * `path` can contain named groups starting with a colon and ending with a star (`:name*`).
|
57
|
+
* All characters are eagerly stored in `$routeParams` under the given `name`
|
62
58
|
* when the route matches.
|
63
59
|
* * `path` can contain optional named groups with a question mark (`:name?`).
|
64
60
|
*
|
@@ -74,9 +70,9 @@ function $RouteProvider(){
|
|
74
70
|
*
|
75
71
|
* Object properties:
|
76
72
|
*
|
77
|
-
* - `controller` – `{(string|function()=}` – Controller fn that should be associated with
|
78
|
-
* created scope or the name of a {@link angular.Module#controller registered
|
79
|
-
* if passed as a string.
|
73
|
+
* - `controller` – `{(string|function()=}` – Controller fn that should be associated with
|
74
|
+
* newly created scope or the name of a {@link angular.Module#controller registered
|
75
|
+
* controller} if passed as a string.
|
80
76
|
* - `controllerAs` – `{string=}` – A controller alias name. If present the controller will be
|
81
77
|
* published to scope under the `controllerAs` name.
|
82
78
|
* - `template` – `{string=|function()=}` – html template as a string or a function that
|
@@ -98,17 +94,22 @@ function $RouteProvider(){
|
|
98
94
|
* `$location.path()` by applying the current route
|
99
95
|
*
|
100
96
|
* - `resolve` - `{Object.<string, function>=}` - An optional map of dependencies which should
|
101
|
-
* be injected into the controller. If any of these dependencies are promises,
|
102
|
-
* resolved
|
103
|
-
*
|
97
|
+
* be injected into the controller. If any of these dependencies are promises, the router
|
98
|
+
* will wait for them all to be resolved or one to be rejected before the controller is
|
99
|
+
* instantiated.
|
100
|
+
* If all the promises are resolved successfully, the values of the resolved promises are
|
101
|
+
* injected and {@link ngRoute.$route#$routeChangeSuccess $routeChangeSuccess} event is
|
102
|
+
* fired. If any of the promises are rejected the
|
103
|
+
* {@link ngRoute.$route#$routeChangeError $routeChangeError} event is fired. The map object
|
104
|
+
* is:
|
104
105
|
*
|
105
106
|
* - `key` – `{string}`: a name of a dependency to be injected into the controller.
|
106
107
|
* - `factory` - `{string|function}`: If `string` then it is an alias for a service.
|
107
108
|
* Otherwise if function, then it is {@link api/AUTO.$injector#invoke injected}
|
108
|
-
* and the return value is treated as the dependency. If the result is a promise, it is
|
109
|
-
* before its value is injected into the controller. Be aware that
|
110
|
-
* still refer to the previous route within these resolve
|
111
|
-
* to access the new route parameters, instead.
|
109
|
+
* and the return value is treated as the dependency. If the result is a promise, it is
|
110
|
+
* resolved before its value is injected into the controller. Be aware that
|
111
|
+
* `ngRoute.$routeParams` will still refer to the previous route within these resolve
|
112
|
+
* functions. Use `$route.current.params` to access the new route parameters, instead.
|
112
113
|
*
|
113
114
|
* - `redirectTo` – {(string|function())=} – value to update
|
114
115
|
* {@link ng.$location $location} path with and trigger route redirection.
|
@@ -123,8 +124,8 @@ function $RouteProvider(){
|
|
123
124
|
* The custom `redirectTo` function is expected to return a string which will be used
|
124
125
|
* to update `$location.path()` and `$location.search()`.
|
125
126
|
*
|
126
|
-
* - `[reloadOnSearch=true]` - {boolean=} - reload route when only
|
127
|
-
*
|
127
|
+
* - `[reloadOnSearch=true]` - {boolean=} - reload route when only `$location.search()`
|
128
|
+
* or `$location.hash()` changes.
|
128
129
|
*
|
129
130
|
* If the option is set to `false` and url in the browser changes, then
|
130
131
|
* `$routeUpdate` event is broadcasted on the root scope.
|
@@ -140,7 +141,7 @@ function $RouteProvider(){
|
|
140
141
|
* Adds a new route definition to the `$route` service.
|
141
142
|
*/
|
142
143
|
this.when = function(path, route) {
|
143
|
-
routes[path] = extend(
|
144
|
+
routes[path] = angular.extend(
|
144
145
|
{reloadOnSearch: true},
|
145
146
|
route,
|
146
147
|
path && pathRegExp(path, route)
|
@@ -149,10 +150,10 @@ function $RouteProvider(){
|
|
149
150
|
// create redirection for trailing slashes
|
150
151
|
if (path) {
|
151
152
|
var redirectPath = (path[path.length-1] == '/')
|
152
|
-
|
153
|
-
|
153
|
+
? path.substr(0, path.length-1)
|
154
|
+
: path +'/';
|
154
155
|
|
155
|
-
routes[redirectPath] = extend(
|
156
|
+
routes[redirectPath] = angular.extend(
|
156
157
|
{redirectTo: path},
|
157
158
|
pathRegExp(redirectPath, route)
|
158
159
|
);
|
@@ -191,7 +192,9 @@ function $RouteProvider(){
|
|
191
192
|
+ (optional ? '' : slash)
|
192
193
|
+ '(?:'
|
193
194
|
+ (optional ? slash : '')
|
194
|
-
+ (star && '(
|
195
|
+
+ (star && '(.+?)' || '([^/]+)')
|
196
|
+
+ (optional || '')
|
197
|
+
+ ')'
|
195
198
|
+ (optional || '');
|
196
199
|
})
|
197
200
|
.replace(/([\/$\*])/g, '\\$1');
|
@@ -218,8 +221,15 @@ function $RouteProvider(){
|
|
218
221
|
};
|
219
222
|
|
220
223
|
|
221
|
-
this.$get = ['$rootScope',
|
222
|
-
|
224
|
+
this.$get = ['$rootScope',
|
225
|
+
'$location',
|
226
|
+
'$routeParams',
|
227
|
+
'$q',
|
228
|
+
'$injector',
|
229
|
+
'$http',
|
230
|
+
'$templateCache',
|
231
|
+
'$sce',
|
232
|
+
function($rootScope, $location, $routeParams, $q, $injector, $http, $templateCache, $sce) {
|
223
233
|
|
224
234
|
/**
|
225
235
|
* @ngdoc object
|
@@ -241,13 +251,16 @@ function $RouteProvider(){
|
|
241
251
|
* @property {Array.<Object>} routes Array of all configured routes.
|
242
252
|
*
|
243
253
|
* @description
|
244
|
-
*
|
254
|
+
* `$route` is used for deep-linking URLs to controllers and views (HTML partials).
|
245
255
|
* It watches `$location.url()` and tries to map the path to an existing route definition.
|
246
256
|
*
|
257
|
+
* Requires the {@link ngRoute `ngRoute`} module to be installed.
|
258
|
+
*
|
247
259
|
* You can define routes through {@link ngRoute.$routeProvider $routeProvider}'s API.
|
248
260
|
*
|
249
|
-
* The `$route` service is typically used in conjunction with
|
250
|
-
*
|
261
|
+
* The `$route` service is typically used in conjunction with the
|
262
|
+
* {@link ngRoute.directive:ngView `ngView`} directive and the
|
263
|
+
* {@link ngRoute.$routeParams `$routeParams`} service.
|
251
264
|
*
|
252
265
|
* @example
|
253
266
|
This example shows how changing the URL hash causes the `$route` to match a route against the
|
@@ -256,7 +269,7 @@ function $RouteProvider(){
|
|
256
269
|
Note that this example is using {@link ng.directive:script inlined templates}
|
257
270
|
to get it working on jsfiddle as well.
|
258
271
|
|
259
|
-
<example module="
|
272
|
+
<example module="ngViewExample" deps="angular-route.js">
|
260
273
|
<file name="index.html">
|
261
274
|
<div ng-controller="MainCntl">
|
262
275
|
Choose:
|
@@ -289,7 +302,9 @@ function $RouteProvider(){
|
|
289
302
|
</file>
|
290
303
|
|
291
304
|
<file name="script.js">
|
292
|
-
angular.module('
|
305
|
+
angular.module('ngViewExample', ['ngRoute'])
|
306
|
+
|
307
|
+
.config(function($routeProvider, $locationProvider) {
|
293
308
|
$routeProvider.when('/Book/:bookId', {
|
294
309
|
templateUrl: 'book.html',
|
295
310
|
controller: BookCntl,
|
@@ -358,6 +373,7 @@ function $RouteProvider(){
|
|
358
373
|
* defined in `resolve` route property. Once all of the dependencies are resolved
|
359
374
|
* `$routeChangeSuccess` is fired.
|
360
375
|
*
|
376
|
+
* @param {Object} angularEvent Synthetic event object.
|
361
377
|
* @param {Route} next Future route information.
|
362
378
|
* @param {Route} current Current route information.
|
363
379
|
*/
|
@@ -374,7 +390,8 @@ function $RouteProvider(){
|
|
374
390
|
*
|
375
391
|
* @param {Object} angularEvent Synthetic event object.
|
376
392
|
* @param {Route} current Current route information.
|
377
|
-
* @param {Route|Undefined} previous Previous route information, or undefined if current is
|
393
|
+
* @param {Route|Undefined} previous Previous route information, or undefined if current is
|
394
|
+
* first route entered.
|
378
395
|
*/
|
379
396
|
|
380
397
|
/**
|
@@ -385,6 +402,7 @@ function $RouteProvider(){
|
|
385
402
|
* @description
|
386
403
|
* Broadcasted if any of the resolve promises are rejected.
|
387
404
|
*
|
405
|
+
* @param {Object} angularEvent Synthetic event object
|
388
406
|
* @param {Route} current Current route information.
|
389
407
|
* @param {Route} previous Previous route information.
|
390
408
|
* @param {Route} rejection Rejection of the promise. Usually the error of the failed promise.
|
@@ -449,13 +467,12 @@ function $RouteProvider(){
|
|
449
467
|
var m = route.regexp.exec(on);
|
450
468
|
if (!m) return null;
|
451
469
|
|
452
|
-
var N = 0;
|
453
470
|
for (var i = 1, len = m.length; i < len; ++i) {
|
454
471
|
var key = keys[i - 1];
|
455
472
|
|
456
473
|
var val = 'string' == typeof m[i]
|
457
|
-
|
458
|
-
|
474
|
+
? decodeURIComponent(m[i])
|
475
|
+
: m[i];
|
459
476
|
|
460
477
|
if (key && val) {
|
461
478
|
params[key.name] = val;
|
@@ -469,9 +486,10 @@ function $RouteProvider(){
|
|
469
486
|
last = $route.current;
|
470
487
|
|
471
488
|
if (next && last && next.$$route === last.$$route
|
472
|
-
&& equals(next.pathParams, last.pathParams)
|
489
|
+
&& angular.equals(next.pathParams, last.pathParams)
|
490
|
+
&& !next.reloadOnSearch && !forceReload) {
|
473
491
|
last.params = next.params;
|
474
|
-
copy(last.params, $routeParams);
|
492
|
+
angular.copy(last.params, $routeParams);
|
475
493
|
$rootScope.$broadcast('$routeUpdate', last);
|
476
494
|
} else if (next || last) {
|
477
495
|
forceReload = false;
|
@@ -479,7 +497,7 @@ function $RouteProvider(){
|
|
479
497
|
$route.current = next;
|
480
498
|
if (next) {
|
481
499
|
if (next.redirectTo) {
|
482
|
-
if (isString(next.redirectTo)) {
|
500
|
+
if (angular.isString(next.redirectTo)) {
|
483
501
|
$location.path(interpolate(next.redirectTo, next.params)).search(next.params)
|
484
502
|
.replace();
|
485
503
|
} else {
|
@@ -492,29 +510,30 @@ function $RouteProvider(){
|
|
492
510
|
$q.when(next).
|
493
511
|
then(function() {
|
494
512
|
if (next) {
|
495
|
-
var locals = extend({}, next.resolve),
|
513
|
+
var locals = angular.extend({}, next.resolve),
|
496
514
|
template, templateUrl;
|
497
515
|
|
498
|
-
forEach(locals, function(value, key) {
|
499
|
-
locals[key] = isString(value) ?
|
516
|
+
angular.forEach(locals, function(value, key) {
|
517
|
+
locals[key] = angular.isString(value) ?
|
518
|
+
$injector.get(value) : $injector.invoke(value);
|
500
519
|
});
|
501
520
|
|
502
|
-
if (isDefined(template = next.template)) {
|
503
|
-
if (isFunction(template)) {
|
521
|
+
if (angular.isDefined(template = next.template)) {
|
522
|
+
if (angular.isFunction(template)) {
|
504
523
|
template = template(next.params);
|
505
524
|
}
|
506
|
-
} else if (isDefined(templateUrl = next.templateUrl)) {
|
507
|
-
if (isFunction(templateUrl)) {
|
525
|
+
} else if (angular.isDefined(templateUrl = next.templateUrl)) {
|
526
|
+
if (angular.isFunction(templateUrl)) {
|
508
527
|
templateUrl = templateUrl(next.params);
|
509
528
|
}
|
510
529
|
templateUrl = $sce.getTrustedResourceUrl(templateUrl);
|
511
|
-
if (isDefined(templateUrl)) {
|
530
|
+
if (angular.isDefined(templateUrl)) {
|
512
531
|
next.loadedTemplateUrl = templateUrl;
|
513
532
|
template = $http.get(templateUrl, {cache: $templateCache}).
|
514
533
|
then(function(response) { return response.data; });
|
515
534
|
}
|
516
535
|
}
|
517
|
-
if (isDefined(template)) {
|
536
|
+
if (angular.isDefined(template)) {
|
518
537
|
locals['$template'] = template;
|
519
538
|
}
|
520
539
|
return $q.all(locals);
|
@@ -525,7 +544,7 @@ function $RouteProvider(){
|
|
525
544
|
if (next == $route.current) {
|
526
545
|
if (next) {
|
527
546
|
next.locals = locals;
|
528
|
-
copy(next.params, $routeParams);
|
547
|
+
angular.copy(next.params, $routeParams);
|
529
548
|
}
|
530
549
|
$rootScope.$broadcast('$routeChangeSuccess', next, last);
|
531
550
|
}
|
@@ -544,10 +563,10 @@ function $RouteProvider(){
|
|
544
563
|
function parseRoute() {
|
545
564
|
// Match a route
|
546
565
|
var params, match;
|
547
|
-
forEach(routes, function(route, path) {
|
566
|
+
angular.forEach(routes, function(route, path) {
|
548
567
|
if (!match && (params = switchRouteMatcher($location.path(), route))) {
|
549
568
|
match = inherit(route, {
|
550
|
-
params: extend({}, $location.search(), params),
|
569
|
+
params: angular.extend({}, $location.search(), params),
|
551
570
|
pathParams: params});
|
552
571
|
match.$$route = route;
|
553
572
|
}
|
@@ -561,8 +580,8 @@ function $RouteProvider(){
|
|
561
580
|
*/
|
562
581
|
function interpolate(string, params) {
|
563
582
|
var result = [];
|
564
|
-
forEach((string||'').split(':'), function(segment, i) {
|
565
|
-
if (i
|
583
|
+
angular.forEach((string||'').split(':'), function(segment, i) {
|
584
|
+
if (i === 0) {
|
566
585
|
result.push(segment);
|
567
586
|
} else {
|
568
587
|
var segmentMatch = segment.match(/(\w+)(.*)/);
|
@@ -586,9 +605,13 @@ ngRouteModule.provider('$routeParams', $RouteParamsProvider);
|
|
586
605
|
* @requires $route
|
587
606
|
*
|
588
607
|
* @description
|
589
|
-
*
|
590
|
-
*
|
591
|
-
*
|
608
|
+
* The `$routeParams` service allows you to retrieve the current set of route parameters.
|
609
|
+
*
|
610
|
+
* Requires the {@link ngRoute `ngRoute`} module to be installed.
|
611
|
+
*
|
612
|
+
* The route parameters are a combination of {@link ng.$location `$location`}'s
|
613
|
+
* {@link ng.$location#methods_search `search()`} and {@link ng.$location#methods_path `path()`}.
|
614
|
+
* The `path` parameters are extracted when the {@link ngRoute.$route `$route`} path is matched.
|
592
615
|
*
|
593
616
|
* In case of parameter name collision, `path` params take precedence over `search` params.
|
594
617
|
*
|
@@ -613,6 +636,8 @@ function $RouteParamsProvider() {
|
|
613
636
|
this.$get = function() { return {}; };
|
614
637
|
}
|
615
638
|
|
639
|
+
ngRouteModule.directive('ngView', ngViewFactory);
|
640
|
+
|
616
641
|
/**
|
617
642
|
* @ngdoc directive
|
618
643
|
* @name ngRoute.directive:ngView
|
@@ -625,6 +650,8 @@ function $RouteParamsProvider() {
|
|
625
650
|
* Every time the current route changes, the included view changes with it according to the
|
626
651
|
* configuration of the `$route` service.
|
627
652
|
*
|
653
|
+
* Requires the {@link ngRoute `ngRoute`} module to be installed.
|
654
|
+
*
|
628
655
|
* @animations
|
629
656
|
* enter - animation is used to bring new content into the browser.
|
630
657
|
* leave - animation is used to animate existing content away.
|
@@ -632,6 +659,7 @@ function $RouteParamsProvider() {
|
|
632
659
|
* The enter and leave animation occur concurrently.
|
633
660
|
*
|
634
661
|
* @scope
|
662
|
+
* @priority 400
|
635
663
|
* @example
|
636
664
|
<example module="ngViewExample" deps="angular-route.js" animations="true">
|
637
665
|
<file name="index.html">
|
@@ -643,8 +671,8 @@ function $RouteParamsProvider() {
|
|
643
671
|
<a href="Book/Gatsby/ch/4?key=value">Gatsby: Ch4</a> |
|
644
672
|
<a href="Book/Scarlet">Scarlet Letter</a><br/>
|
645
673
|
|
646
|
-
<div class="
|
647
|
-
<div ng-view class="view-
|
674
|
+
<div class="view-animate-container">
|
675
|
+
<div ng-view class="view-animate"></div>
|
648
676
|
</div>
|
649
677
|
<hr />
|
650
678
|
|
@@ -672,7 +700,9 @@ function $RouteParamsProvider() {
|
|
672
700
|
</file>
|
673
701
|
|
674
702
|
<file name="animations.css">
|
675
|
-
.
|
703
|
+
.view-animate-container {
|
704
|
+
position:relative;
|
705
|
+
height:100px!important;
|
676
706
|
position:relative;
|
677
707
|
background:white;
|
678
708
|
border:1px solid black;
|
@@ -680,14 +710,12 @@ function $RouteParamsProvider() {
|
|
680
710
|
overflow:hidden;
|
681
711
|
}
|
682
712
|
|
683
|
-
.
|
713
|
+
.view-animate {
|
684
714
|
padding:10px;
|
685
715
|
}
|
686
716
|
|
687
|
-
.view-
|
717
|
+
.view-animate.ng-enter, .view-animate.ng-leave {
|
688
718
|
-webkit-transition:all cubic-bezier(0.250, 0.460, 0.450, 0.940) 1.5s;
|
689
|
-
-moz-transition:all cubic-bezier(0.250, 0.460, 0.450, 0.940) 1.5s;
|
690
|
-
-o-transition:all cubic-bezier(0.250, 0.460, 0.450, 0.940) 1.5s;
|
691
719
|
transition:all cubic-bezier(0.250, 0.460, 0.450, 0.940) 1.5s;
|
692
720
|
|
693
721
|
display:block;
|
@@ -702,39 +730,33 @@ function $RouteParamsProvider() {
|
|
702
730
|
padding:10px;
|
703
731
|
}
|
704
732
|
|
705
|
-
.
|
706
|
-
position:relative;
|
707
|
-
height:100px;
|
708
|
-
}
|
709
|
-
|
710
|
-
.view-example.ng-enter {
|
733
|
+
.view-animate.ng-enter {
|
711
734
|
left:100%;
|
712
735
|
}
|
713
|
-
.view-
|
736
|
+
.view-animate.ng-enter.ng-enter-active {
|
714
737
|
left:0;
|
715
738
|
}
|
716
|
-
|
717
|
-
.view-example.ng-leave { }
|
718
|
-
.view-example.ng-leave.ng-leave-active {
|
739
|
+
.view-animate.ng-leave.ng-leave-active {
|
719
740
|
left:-100%;
|
720
741
|
}
|
721
742
|
</file>
|
722
743
|
|
723
744
|
<file name="script.js">
|
724
|
-
angular.module('ngViewExample', ['ngRoute', 'ngAnimate'],
|
725
|
-
$routeProvider
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
745
|
+
angular.module('ngViewExample', ['ngRoute', 'ngAnimate'],
|
746
|
+
function($routeProvider, $locationProvider) {
|
747
|
+
$routeProvider.when('/Book/:bookId', {
|
748
|
+
templateUrl: 'book.html',
|
749
|
+
controller: BookCntl,
|
750
|
+
controllerAs: 'book'
|
751
|
+
});
|
752
|
+
$routeProvider.when('/Book/:bookId/ch/:chapterId', {
|
753
|
+
templateUrl: 'chapter.html',
|
754
|
+
controller: ChapterCntl,
|
755
|
+
controllerAs: 'chapter'
|
756
|
+
});
|
757
|
+
|
758
|
+
// configure html5 to get links working on jsfiddle
|
759
|
+
$locationProvider.html5Mode(true);
|
738
760
|
});
|
739
761
|
|
740
762
|
function MainCntl($route, $routeParams, $location) {
|
@@ -780,22 +802,19 @@ function $RouteParamsProvider() {
|
|
780
802
|
* @description
|
781
803
|
* Emitted every time the ngView content is reloaded.
|
782
804
|
*/
|
783
|
-
|
784
|
-
|
785
|
-
function($route, $anchorScroll, $compile, $controller, $animate) {
|
805
|
+
ngViewFactory.$inject = ['$route', '$anchorScroll', '$compile', '$controller', '$animate'];
|
806
|
+
function ngViewFactory( $route, $anchorScroll, $compile, $controller, $animate) {
|
786
807
|
return {
|
787
808
|
restrict: 'ECA',
|
788
809
|
terminal: true,
|
789
|
-
priority:
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
return function(scope) {
|
798
|
-
var currentScope, currentElement;
|
810
|
+
priority: 400,
|
811
|
+
transclude: 'element',
|
812
|
+
compile: function(element, attr, linker) {
|
813
|
+
return function(scope, $element, attr) {
|
814
|
+
var currentScope,
|
815
|
+
currentElement,
|
816
|
+
autoScrollExp = attr.autoscroll,
|
817
|
+
onloadExp = attr.onload || '';
|
799
818
|
|
800
819
|
scope.$on('$routeChangeSuccess', update);
|
801
820
|
update();
|
@@ -816,45 +835,46 @@ var ngViewDirective = ['$route', '$anchorScroll', '$compile', '$controller', '$a
|
|
816
835
|
template = locals && locals.$template;
|
817
836
|
|
818
837
|
if (template) {
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
838
|
+
var newScope = scope.$new();
|
839
|
+
linker(newScope, function(clone) {
|
840
|
+
clone.html(template);
|
841
|
+
$animate.enter(clone, null, currentElement || $element, function onNgViewEnter () {
|
842
|
+
if (angular.isDefined(autoScrollExp)
|
843
|
+
&& (!autoScrollExp || scope.$eval(autoScrollExp))) {
|
844
|
+
$anchorScroll();
|
845
|
+
}
|
846
|
+
});
|
828
847
|
|
829
|
-
|
830
|
-
locals.$scope = currentScope;
|
831
|
-
var controller = $controller(current.controller, locals);
|
832
|
-
if (current.controllerAs) {
|
833
|
-
currentScope[current.controllerAs] = controller;
|
834
|
-
}
|
835
|
-
currentElement.data('$ngControllerController', controller);
|
836
|
-
currentElement.children().data('$ngControllerController', controller);
|
837
|
-
}
|
848
|
+
cleanupLastView();
|
838
849
|
|
839
|
-
|
850
|
+
var link = $compile(clone.contents()),
|
851
|
+
current = $route.current;
|
840
852
|
|
841
|
-
|
853
|
+
currentScope = current.scope = newScope;
|
854
|
+
currentElement = clone;
|
842
855
|
|
843
|
-
|
844
|
-
|
856
|
+
if (current.controller) {
|
857
|
+
locals.$scope = currentScope;
|
858
|
+
var controller = $controller(current.controller, locals);
|
859
|
+
if (current.controllerAs) {
|
860
|
+
currentScope[current.controllerAs] = controller;
|
861
|
+
}
|
862
|
+
clone.data('$ngControllerController', controller);
|
863
|
+
clone.children().data('$ngControllerController', controller);
|
864
|
+
}
|
845
865
|
|
846
|
-
|
847
|
-
|
866
|
+
link(currentScope);
|
867
|
+
currentScope.$emit('$viewContentLoaded');
|
868
|
+
currentScope.$eval(onloadExp);
|
869
|
+
});
|
848
870
|
} else {
|
849
871
|
cleanupLastView();
|
850
872
|
}
|
851
873
|
}
|
852
|
-
}
|
874
|
+
};
|
853
875
|
}
|
854
876
|
};
|
855
|
-
}
|
856
|
-
|
857
|
-
ngRouteModule.directive('ngView', ngViewDirective);
|
877
|
+
}
|
858
878
|
|
859
879
|
|
860
880
|
})(window, window.angular);
|