AngularJS $routeParams vs $stateParams

偶尔善良 提交于 2019-12-10 02:47:00

问题


What is the difference between:

$routeParams and $stateParams

and when to use what?


回答1:


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

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.

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

See more: http://www.amasik.com/angularjs-ngroute-vs-ui-router/



来源:https://stackoverflow.com/questions/26946800/angularjs-routeparams-vs-stateparams

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!