What is the difference in angularJS between ui.router and ui.state?

时光总嘲笑我的痴心妄想 提交于 2019-12-23 07:08:55

问题


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:


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']);


来源:https://stackoverflow.com/questions/19964629/what-is-the-difference-in-angularjs-between-ui-router-and-ui-state

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!