ui.router 和 ui.state 之间的 angularJS 有什么区别? [英] What is the difference in angularJS between ui.router and ui.state?

查看:20
本文介绍了ui.router 和 ui.state 之间的 angularJS 有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 angular ui-router 获得具有多个视图的 angularJS SPA 设置.

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

当我在网上查看教程和操作方法时,我看到了各种依赖项.ui-router github 页面有使用 ui.router 作为模块依赖的例子,而其他文章如 Ben Schwartz 教程 使用 ui.state.

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.

有什么区别?一个被弃用了吗?ui.stateui.router 的子集吗?

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

推荐答案

总而言之,ui.state 适用于 v0.0.1,而 ui.router 适用于 v0.2.0(当前版本).

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

ui.state 是用户在 ui-router v0.0.1 中作为依赖注入的必要模块.请参阅该版本中的README,以及来自angular-ui-router.js(第 45-48 行):

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

v0.2.0 中的 自述文件在快速入门下说明:将 ui.router 设置为模块中的依赖项.注意:如果使用 v0.0.1,请使用 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.

这当然得到 angular-ui-router 的证实.js 在 v0.2.0,第 79-83 行,显示了此时对应的模块依赖结构:

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

这篇关于ui.router 和 ui.state 之间的 angularJS 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆