问题描述
限时送ChatGPT账号..有什么区别:
$routeParams and $stateParams
何时使用什么?
推荐答案
两者都来自不同的路由器模块.您可以在应用程序中使用任何人.
Both are from different router modules. You can use anyone in your application.
如果你使用 ngRoute
模块,那么你应该使用 $routeParams
( https://docs.angularjs/api/ngRoute ).这是由 Angular 团队提供的.它只有一个 ng-view
.您不能执行嵌套视图功能.
If you use ngRoute
module, then you should use $routeParams
( https://docs.angularjs/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/angular-ui/ui-router).这是来自贡献的模块.与 ngRoute
相比,它具有更多的附加功能.它支持嵌套视图概念.你可以指定多个 ui-view
If you use ui-router
module, then you should use $stateParams
( https://github/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/angularjs-ngroute-vs-ui-路由器/
这篇关于AngularJS $routeParams 与 $stateParams的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论