Multiple Layers of Deep Linking in AngularJS

让人想犯罪 __ 提交于 2019-12-22 20:52:21

问题


I am attempting to place multiple controllers within my template partials with AngularJS- The problem I am encountering is that of the first layer, direct-linking to these sub-controllers and their related snippets.

An example would be a management page for user accounts, say I am on a user-list and wanted to change a user from the list's password, I click on their change-password button, and want to redirect the user to #/ManageUsers/ChangePassword/?UserID=<uid here> rather than #/ManageUsers_ChangePassword/ or similar, but the Angular documentation (Or lack thereof) on the subject suggests that this is impossible, or not 'The Angular Way'...

Being that my team wants to keep these separate controllers as partials, is there a non-hacky way to do this with Angular?


回答1:


why not direct to #/ManageUsers/ChangePassword/:UserID ? You can get the UserID from $routeParams. See an example on the $route page.

You can even create routes like #/ManageUsers/:OrganizationID/:SectorId/:UserID/ChangePassword/Confirmation that will be used by the url #/ManageUsers/10/2/32/ChangePassword/Confirmation




回答2:


There has been recently published a blog post about one possible way of solving deep linking with AngularJS. It has a parent/child style of implementation where parent sections do not need to be updated if you need to change only contents of the child, which makes it pretty neat.

It's here: http://www.bennadel.com/blog/2441-Nested-Views-Routing-And-Deep-Linking-With-AngularJS.htm



来源:https://stackoverflow.com/questions/11377676/multiple-layers-of-deep-linking-in-angularjs

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