Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Master #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
tinybull wants to merge 2 commits into subchen:master
base: master
Choose a base branch
Loading
from tinybull:master
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
路由设置
当主模块的requires数组中没有声明依赖路由模块,而路由被主模块中的依赖所依赖,那么应该重新定义路由
  • Loading branch information
tiny committed Nov 17, 2016
commit b630f729b2a40afc503e96490c95c3f8ea2efb78
48 changes: 31 additions & 17 deletions angular-async-loader.js
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -212,24 +212,38 @@

}]);

// rewrite $routeProvider.when
if (app.requires && app.requires.indexOf('ngRoute') !== -1) {
app.config(['$routeProvider', function($routeProvider) {
var whenFn = $routeProvider.when;
$routeProvider.when = function(path, config) {
return whenFn.call($routeProvider, path, route(config));
};
}]);
}
// rewrite $stateProvider.state
if (app.requires && app.requires.indexOf('ui.router') !== -1) {
app.config(['$stateProvider', function($stateProvider) {
var stateFn = $stateProvider.state;
$stateProvider.state = function(state, config) {
return stateFn.call($stateProvider, state, route(config));
};
}]);

// rewrite router
function rewriteRoute(requires) {
if (requires.length == 0) {
return;
}
for (var i = 0; i < requires.length; i++) {

//rewrite $routeProvider.when
if (requires[i] === 'ui.router') {
app.config(['$stateProvider', function ($stateProvider) {
var stateFn = $stateProvider.state;
$stateProvider.state = function (state, config) {
return stateFn.call($stateProvider, state, route(config));
};
}]);
}

// rewrite $stateProvider.state
if (requires[i] === 'ngRoute') {
app.config(['$routeProvider', function ($routeProvider) {
var whenFn = $routeProvider.when;
$routeProvider.when = function (path, config) {
return whenFn.call($routeProvider, path, route(config));
};
}]);
}
rewriteRoute(app.module(requires[i]).requires);

}
}
rewriteRoute(app.requires);
}
};
}
Expand Down

AltStyle によって変換されたページ (->オリジナル) /