AngularJS $ routeParams VS $ stateParams [英] AngularJS $routeParams vs $stateParams

查看:772
本文介绍了AngularJS $ routeParams VS $ stateParams的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

之间有什么区别:

$routeParams and $stateParams

和什么时候使用什么?

推荐答案

两者都是从不同的路由器模块。您可以在应用程序中使用的任何人。

Both are from different router modules. You can use anyone in your application.

如果您使用 ngRoute 模块,那么你应该使用 $ routeParams
https://docs.angularjs.org/api/ngRoute )。这是由角团队提供。它只有一个 NG-视图。你不能做嵌套视图功能。

If you use ngRoute module, then you should use $routeParams ( https://docs.angularjs.org/api/ngRoute ) . This is provided by Angular team. It has only one ng-view. you can not do nested views functionality.

如果您使用 UI路由器模块,那么你应该使用 $ stateParams
https://github.com/angular-ui/ui-router )。这是从贡献模块。它有更多的功能数量比较比 ngRoute 。它支持嵌套视图的概念。可以指定多个用户界面视图

If you use ui-router module, then you should use $stateParams ( https://github.com/angular-ui/ui-router ). This is from contributed module. It has number of additional functionality compare than ngRoute . It supports nested view concepts. you can specify multiple ui-view

查看更多:<一href=\"http://www.amasik.com/angularjs-ngroute-vs-ui-router/\">http://www.amasik.com/angularjs-ngroute-vs-ui-router/

这篇关于AngularJS $ routeParams VS $ stateParams的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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