Skip to content

Commit 554e73c

Browse files
Revert "made .when defer till runtime"
This reverts commit 97f8d90.
1 parent 7186651 commit 554e73c

File tree

1 file changed

+4
-18
lines changed

1 file changed

+4
-18
lines changed

src/urlRouter.js

+4-18
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717
$UrlRouterProvider.$inject = ['$locationProvider', '$urlMatcherFactoryProvider'];
1818
function $UrlRouterProvider( $locationProvider, $urlMatcherFactory) {
19-
var self = this, rules = [], otherwise = null, interceptDeferred = false, listener;
19+
var rules = [], otherwise = null, interceptDeferred = false, listener;
2020

2121
// Returns a string that is a prefix of all strings matching the RegExp
2222
function regExpPrefix(re) {
@@ -154,20 +154,6 @@ function $UrlRouterProvider( $locationProvider, $urlMatcherFactory) {
154154
* @param {string|object} handler The path you want to redirect your user to.
155155
*/
156156
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) {
171157
var redirect, handlerIsString = isString(handler);
172158
if (isString(what)) what = $urlMatcherFactory.compile(what);
173159

@@ -204,11 +190,11 @@ function $UrlRouterProvider( $locationProvider, $urlMatcherFactory) {
204190
var check = { matcher: $urlMatcherFactory.isMatcher(what), regex: what instanceof RegExp };
205191

206192
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));
208194
}
209195

210196
throw new Error("invalid 'what' in when()");
211-
}
197+
};
212198

213199
/**
214200
* @ngdoc function
@@ -278,7 +264,7 @@ function $UrlRouterProvider( $locationProvider, $urlMatcherFactory) {
278264
this.$get = $get;
279265
$get.$inject = ['$location', '$rootScope', '$injector', '$browser'];
280266
function $get( $location, $rootScope, $injector, $browser) {
281-
flushWhenQueue();
267+
282268
var baseHref = $browser.baseHref(), location = $location.url();
283269

284270
function appendBasePath(url, isHtml5, absolute) {

0 commit comments

Comments
 (0)