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

查看:37
本文介绍了AngularJS $routeParams 与 $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 ).这是由 Angular 团队提供的.它只有一个 ng-view.您不能执行嵌套视图功能.

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-router 模块,那么你应该使用 $stateParams( https://github.com/angular-ui/ui-router).这是来自贡献的模块.与 ngRoute 相比,它具有更多的附加功能.它支持嵌套视图概念.你可以指定多个 ui-view

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

查看更多:http://www.amasik.com/angularjs-ngroute-vs-ui-路由器/

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

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