Skip to content

Commit 52d3d42

Browse files
committed
v1.3.0-build.3342+sha.feba017
1 parent 8d0eb5f commit 52d3d42

File tree

4 files changed

+64
-32
lines changed

4 files changed

+64
-32
lines changed

angular-route.js

+51-19
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @license AngularJS v1.2.27-build.496+sha.d7c084f
2+
* @license AngularJS v1.3.0-build.3342+sha.feba017
33
* (c) 2010-2014 Google, Inc. http://angularjs.org
44
* License: MIT
55
*/
@@ -22,12 +22,12 @@
2222
*/
2323
/* global -ngRouteModule */
2424
var ngRouteModule = angular.module('ngRoute', ['ng']).
25-
provider('$route', $RouteProvider);
25+
provider('$route', $RouteProvider),
26+
$routeMinErr = angular.$$minErr('ngRoute');
2627

2728
/**
2829
* @ngdoc provider
2930
* @name $routeProvider
30-
* @kind function
3131
*
3232
* @description
3333
*
@@ -216,10 +216,14 @@ function $RouteProvider(){
216216
* Sets route definition that will be used on route change when no other route definition
217217
* is matched.
218218
*
219-
* @param {Object} params Mapping information to be assigned to `$route.current`.
219+
* @param {Object|string} params Mapping information to be assigned to `$route.current`.
220+
* If called with a string, the value maps to `redirectTo`.
220221
* @returns {Object} self
221222
*/
222223
this.otherwise = function(params) {
224+
if (typeof params === 'string') {
225+
params = {redirectTo: params};
226+
}
223227
this.when(null, params);
224228
return this;
225229
};
@@ -230,10 +234,9 @@ function $RouteProvider(){
230234
'$routeParams',
231235
'$q',
232236
'$injector',
233-
'$http',
234-
'$templateCache',
237+
'$templateRequest',
235238
'$sce',
236-
function($rootScope, $location, $routeParams, $q, $injector, $http, $templateCache, $sce) {
239+
function($rootScope, $location, $routeParams, $q, $injector, $templateRequest, $sce) {
237240

238241
/**
239242
* @ngdoc service
@@ -438,6 +441,36 @@ function $RouteProvider(){
438441
reload: function() {
439442
forceReload = true;
440443
$rootScope.$evalAsync(updateRoute);
444+
},
445+
446+
/**
447+
* @ngdoc method
448+
* @name $route#updateParams
449+
*
450+
* @description
451+
* Causes `$route` service to update the current URL, replacing
452+
* current route parameters with those specified in `newParams`.
453+
* Provided property names that match the route's path segment
454+
* definitions will be interpolated into the location's path, while
455+
* remaining properties will be treated as query params.
456+
*
457+
* @param {Object} newParams mapping of URL parameter names to values
458+
*/
459+
updateParams: function(newParams) {
460+
if (this.current && this.current.$$route) {
461+
var searchParams = {}, self=this;
462+
463+
angular.forEach(Object.keys(newParams), function(key) {
464+
if (!self.current.pathParams[key]) searchParams[key] = newParams[key];
465+
});
466+
467+
newParams = angular.extend({}, this.current.params, newParams);
468+
$location.path(interpolate(this.current.$$route.originalPath, newParams));
469+
$location.search(angular.extend({}, $location.search(), searchParams));
470+
}
471+
else {
472+
throw $routeMinErr('norout', 'Tried updating route when with no current route');
473+
}
441474
}
442475
};
443476

@@ -513,7 +546,7 @@ function $RouteProvider(){
513546

514547
angular.forEach(locals, function(value, key) {
515548
locals[key] = angular.isString(value) ?
516-
$injector.get(value) : $injector.invoke(value);
549+
$injector.get(value) : $injector.invoke(value, null, null, key);
517550
});
518551

519552
if (angular.isDefined(template = next.template)) {
@@ -527,8 +560,7 @@ function $RouteProvider(){
527560
templateUrl = $sce.getTrustedResourceUrl(templateUrl);
528561
if (angular.isDefined(templateUrl)) {
529562
next.loadedTemplateUrl = templateUrl;
530-
template = $http.get(templateUrl, {cache: $templateCache}).
531-
then(function(response) { return response.data; });
563+
template = $templateRequest(templateUrl);
532564
}
533565
}
534566
if (angular.isDefined(template)) {
@@ -690,7 +722,6 @@ ngRouteModule.directive('ngView', ngViewFillContentFactory);
690722
<pre>$location.path() = {{main.$location.path()}}</pre>
691723
<pre>$route.current.templateUrl = {{main.$route.current.templateUrl}}</pre>
692724
<pre>$route.current.params = {{main.$route.current.params}}</pre>
693-
<pre>$route.current.scope.name = {{main.$route.current.scope.name}}</pre>
694725
<pre>$routeParams = {{main.$routeParams}}</pre>
695726
</div>
696727
</file>
@@ -823,27 +854,28 @@ function ngViewFactory( $route, $anchorScroll, $animate) {
823854
link: function(scope, $element, attr, ctrl, $transclude) {
824855
var currentScope,
825856
currentElement,
826-
previousElement,
857+
previousLeaveAnimation,
827858
autoScrollExp = attr.autoscroll,
828859
onloadExp = attr.onload || '';
829860

830861
scope.$on('$routeChangeSuccess', update);
831862
update();
832863

833864
function cleanupLastView() {
834-
if(previousElement) {
835-
previousElement.remove();
836-
previousElement = null;
865+
if(previousLeaveAnimation) {
866+
$animate.cancel(previousLeaveAnimation);
867+
previousLeaveAnimation = null;
837868
}
869+
838870
if(currentScope) {
839871
currentScope.$destroy();
840872
currentScope = null;
841873
}
842874
if(currentElement) {
843-
$animate.leave(currentElement, function() {
844-
previousElement = null;
875+
previousLeaveAnimation = $animate.leave(currentElement);
876+
previousLeaveAnimation.then(function() {
877+
previousLeaveAnimation = null;
845878
});
846-
previousElement = currentElement;
847879
currentElement = null;
848880
}
849881
}
@@ -863,7 +895,7 @@ function ngViewFactory( $route, $anchorScroll, $animate) {
863895
// function is called before linking the content, which would apply child
864896
// directives to non existing elements.
865897
var clone = $transclude(newScope, function(clone) {
866-
$animate.enter(clone, null, currentElement || $element, function onNgViewEnter () {
898+
$animate.enter(clone, null, currentElement || $element).then(function onNgViewEnter () {
867899
if (angular.isDefined(autoScrollExp)
868900
&& (!autoScrollExp || scope.$eval(autoScrollExp))) {
869901
$anchorScroll();

angular-route.min.js

+9-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)