AngularJS:角路线和角度的UI路由器之间的区别 [英] AngularJS : Difference between angular-route and angular-ui-router

查看:135
本文介绍了AngularJS:角路线和角度的UI路由器之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来AngularJS。我觉得角度很有趣,规划在我的大的应用程序使用的角度。所以我在这个过程中,找出合适的模块来使用。

I am new to AngularJS. I find Angular quite interesting and planning to use angular in my big apps. So I am in the process to find out the right modules to use.

之间有什么区别的 ngRoute(角route.js) UI路由器(角-UI-router.js)模块?

What is the difference between ngRoute (angular-route.js) and ui-router (angular-ui-router.js) modules?

在使用时的 ngRoute 的文章很多,路由配置是 $ routeProvider 。然而,随着的 UI路由器的,路由配置与使用时的 $ stateProvider和$ urlRouterProvider

In many articles when ngRoute is used, route is configured with $routeProvider. However, when used with ui-router, route is configured with $stateProvider and $urlRouterProvider.

这对我造成了一些混乱。哪个模块我应该使用更好的可管理性和可扩展性?你的回答是大大AP preciated。

This creates a bit of confusion for me. Which module should I use for better manageability and extensibility? Your answers are greatly appreciated.

推荐答案

UI路由器是一个3rd-党的模块是非常强大的。它支持一切正常ngRoute可以做的还有很多额外的功能。

ui-router is a 3rd-party module and is very powerful. It supports everything the normal ngRoute can do as well as many extra functions.

下面是一些常见的原因UI的路由器选择了在ngRoute:

Here are some common reason ui-router is chosen over ngRoute:

  • ui-router allows for nested views and multiple named views. This is very useful with larger app where you may have pages that inherit from other sections.

UI路由器允许你有基于状态的名称国家之间的强类型的链接。在一个地方更改URL时你建立你的链接将更新每个链接到该状态<一个href=\"http://angular-ui.github.io/ui-router/site/#/api/ui.router.state.directive:ui-sref\"><$c$c>ui-sref.对于其中的网址可能会改变较大的项目中非常有用的。

ui-router allows for you to have strong-type linking between states based on state names. Change the url in one place will update every link to that state when you build your links with ui-sref. Very useful for larger projects where URLs might change.

还有的概念<一href=\"http://angular-ui.github.io/ui-router/site/#/api/ui.router.state.$stateProvider#methods_decorator\">decorator这可用于允许基于被试图访问的URL来动态创建的路线。这可能意味着你将不再需要用手之前指定的所有路由的。

There is also the concept of the decorator which could be used to allow your routes to be dynamically created based on the URL that is trying to be accessed. This could mean that you will not need to specify all of your routes before hand.

允许你映射和访问有关不同状态​​的不同信息你可以很容易地通过<一个通过国家之间的信息href=\"https://github.com/angular-ui/ui-router/wiki/URL-Routing#stateparams-service\"><$c$c>$stateParams.

states allow you to map and access different information about different states and you can easily pass information between states via $stateParams.

您可以很容易地确定,如果你是在一个国家的状态或者通过母公司<一个你的模板内调整UI元素(高亮显示当前状态的导航) href=\"http://angular-ui.github.io/ui-router/site/#/api/ui.router.state.$state\"><$c$c>$state通过UI路由器,你可以通过在运行

You can easily determine if you are in a state or parent of a state to adjust UI element (highlighting the navigation of the current state) within your templates via $state provided by ui-router which you can expose via setting it in $rootScope on run.

在本质上,用户界面​​路由器是ngRouter有更多的功能,所述片材在它之下是完全不同的。这些附加功能是非常有用的较大的应用程序。

In essence, ui-router is ngRouter with more features, under the sheets it is quite different. These additional features are very useful for larger applications.

更多信息:


  • Github上: https://github.com/angular-ui/ui-router

  • 文档:

    • API参考:<一href=\"http://angular-ui.github.io/ui-router/site/#/api\">http://angular-ui.github.io/ui-router/site/#/api

    • 指南:<一href=\"https://github.com/angular-ui/ui-router/wiki\">https://github.com/angular-ui/ui-router/wiki

    • Github: https://github.com/angular-ui/ui-router
    • Documentation:
      • API Reference: http://angular-ui.github.io/ui-router/site/#/api
      • Guide: https://github.com/angular-ui/ui-router/wiki

      这篇关于AngularJS:角路线和角度的UI路由器之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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