Angular-UI-Router: should i avoid href with ui-router?

岁酱吖の 提交于 2019-12-24 10:45:34

问题


Looking through the reference to ui-router (https://github.com/angular-ui/ui-router/wiki/Quick-Reference#ui-sref) the following is said about ui-sref:

the directive will automatically generate & update the href attribute via the $state.href() method

All things considered, this essentially makes ui-sref a full replacement to href: not only it works with states, but also takes care of url.

Does it mean that in an angular ui-router app it is best to avoid hrefs even for global, SPA-wide pages and use ui-sref exclusively for navigation?


回答1:


Actually, hrefs might be quite useful with late-stage state bounding (achieved with FutureStates https://christopherthielen.github.io/ui-router-extras/#/future)

While the nested state itself might not yet be loaded at the point of rendering ui-sref, href is always available and can point to any future state.

There might be a way to define a skeleton for nested states inside FutureState, but none that I aware of.



来源:https://stackoverflow.com/questions/43155308/angular-ui-router-should-i-avoid-href-with-ui-router

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