|
16 | 16 | */
|
17 | 17 | $UrlRouterProvider.$inject = ['$locationProvider', '$urlMatcherFactoryProvider'];
|
18 | 18 | function $UrlRouterProvider( $locationProvider, $urlMatcherFactory) {
|
19 |
| - var self = this, rules = [], otherwise = null, interceptDeferred = false, listener; |
| 19 | + var rules = [], otherwise = null, interceptDeferred = false, listener; |
20 | 20 |
|
21 | 21 | // Returns a string that is a prefix of all strings matching the RegExp
|
22 | 22 | function regExpPrefix(re) {
|
@@ -154,20 +154,6 @@ function $UrlRouterProvider( $locationProvider, $urlMatcherFactory) {
|
154 | 154 | * @param {string|object} handler The path you want to redirect your user to.
|
155 | 155 | */
|
156 | 156 | this.when = function (what, handler) {
|
157 |
| - if (whenQueue) |
158 |
| - whenQueue.push({ what: what, handler: handler }); |
159 |
| - else |
160 |
| - _when(what, handler); |
161 |
| - return self; |
162 |
| - }; |
163 |
| - |
164 |
| - var whenQueue = []; |
165 |
| - function flushWhenQueue() { |
166 |
| - forEach(whenQueue, function(queuedWhen) { _when(queuedWhen.what, queuedWhen.handler); }); |
167 |
| - whenQueue = null; |
168 |
| - } |
169 |
| - |
170 |
| - function _when(what, handler) { |
171 | 157 | var redirect, handlerIsString = isString(handler);
|
172 | 158 | if (isString(what)) what = $urlMatcherFactory.compile(what);
|
173 | 159 |
|
@@ -204,11 +190,11 @@ function $UrlRouterProvider( $locationProvider, $urlMatcherFactory) {
|
204 | 190 | var check = { matcher: $urlMatcherFactory.isMatcher(what), regex: what instanceof RegExp };
|
205 | 191 |
|
206 | 192 | for (var n in check) {
|
207 |
| - if (check[n]) return self.rule(strategies[n](what, handler)); |
| 193 | + if (check[n]) return this.rule(strategies[n](what, handler)); |
208 | 194 | }
|
209 | 195 |
|
210 | 196 | throw new Error("invalid 'what' in when()");
|
211 |
| - } |
| 197 | + }; |
212 | 198 |
|
213 | 199 | /**
|
214 | 200 | * @ngdoc function
|
@@ -278,7 +264,7 @@ function $UrlRouterProvider( $locationProvider, $urlMatcherFactory) {
|
278 | 264 | this.$get = $get;
|
279 | 265 | $get.$inject = ['$location', '$rootScope', '$injector', '$browser'];
|
280 | 266 | function $get( $location, $rootScope, $injector, $browser) {
|
281 |
| - flushWhenQueue(); |
| 267 | + |
282 | 268 | var baseHref = $browser.baseHref(), location = $location.url();
|
283 | 269 |
|
284 | 270 | function appendBasePath(url, isHtml5, absolute) {
|
|
0 commit comments