What is the difference in angularJS between ui.rou

2019-06-15 13:46发布

I am working on getting an angularJS SPA setup with multiple views using angular ui-router.

As I look aroun dthe web at tutorials and how-to's, I see a mixed bag of dependencies. The ui-router github page has examples that use ui.router as the module dependency, while other articles such as Ben Schwartz tutorial uses ui.state.

What is the difference? Is one deprecated? Is ui.state a subset of ui.router?

1条回答
干净又极端
2楼-- · 2019-06-15 14:03

In summary, ui.state was for v0.0.1, while ui.router is for v0.2.0 (the current version).

ui.state was the necessary module for users to inject as a dependency in v0.0.1 of ui-router. See the README at that release, as well as the relevant snippet from angular-ui-router.js (lines 45-48):

angular.module('ui.util', ['ng']);
angular.module('ui.router', ['ui.util']);
angular.module('ui.state', ['ui.router', 'ui.util']);
angular.module('ui.compat', ['ui.state']);

The README at v0.2.0 states under Quick Start: Set ui.router as a dependency in your module. Note: Use ui.state if using v0.0.1.

This is of course corroborated by angular-ui-router.js at v0.2.0, lines 79-83, showing the corresponding module dependency structure at that point:

angular.module('ui.router.util', ['ng']);
angular.module('ui.router.router', ['ui.router.util']);
angular.module('ui.router.state', ['ui.router.router', 'ui.router.util']);
angular.module('ui.router', ['ui.router.state']);
angular.module('ui.router.compat', ['ui.router']);
查看更多
登录 后发表回答