This repository was archived by the owner on Apr 12, 2024. It is now read-only.
Commit 7f4b356
fix($route): don't process route change controllers and templates for
If a route defines a `redirectTo` value, the current route should stop processing the route
and instead wait to process the route of the redirect.
Currently, what is happening is that Angular detects a redirectTo value and updates $location,
but then continues processing the route that was intended to be redirected.
Templates are loaded, resolves are processed, ng-view then updates the view with a new template
and instantiates the controller all for a route that should have been redirected.
A common use case for assigning a function to the redirectTo is to validation authentication,
permission check, or some other logic to determine if the route should continue or redirect
else where. In the end, this happens, but in between, unexpected results may occur by updating
the view and instantiating controllers for logic that wasn't expected to be executed.
http://plnkr.co/edit/8QlA0ouuePH3p35Ntmjy?p=preview
This commit checks for a url change after a potential redirect, it the url changed, and is
not `null` nor `undefined`, exit out and don't process current route change.
Closes #3332
Closes #14658
BREAKING CHANGE
The $route service no longer instantiates controllers nor calls resolves or template functions
for routes that have a `redirectTo` unless the `redirectTo` is a function that returns
`undefined`.redirectTo routes1 parent 4c95ad8 commit 7f4b356
2 files changed
+74
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
139 | 145 | | |
140 | 146 | | |
141 | 147 | | |
| |||
588 | 594 | | |
589 | 595 | | |
590 | 596 | | |
| 597 | + | |
| 598 | + | |
591 | 599 | | |
592 | | - | |
| 600 | + | |
| 601 | + | |
593 | 602 | | |
| 603 | + | |
594 | 604 | | |
595 | | - | |
596 | | - | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
597 | 610 | | |
598 | 611 | | |
599 | 612 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1061 | 1061 | | |
1062 | 1062 | | |
1063 | 1063 | | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
1064 | 1122 | | |
1065 | 1123 | | |
1066 | 1124 | | |
| |||
0 commit comments