How to hide url in angular?

守給你的承諾、 提交于 2019-12-12 00:38:59

问题


Is it possible to not using angualar routes, because if I defined an routes like:

app.config(function($routeProvider){
    $routeProvider.when('/home')
})

my url will look like www.app.com/#home,

I dont want to change url, just www.app.com nice and clean, in this case how to defined template for defferent controller and how to load the template in ng-view, and how to pass url parameter?

any idea?


回答1:


You cannot do that with the built-in routing mechanism because path is required for every route. However, you can use ui-router library in order to create URL-less states and navigate to them using either code or directive.

I created this plunker to demonstrate how to use ui-router to navigate among states without modifying URL.



来源:https://stackoverflow.com/questions/18435967/how-to-hide-url-in-angular

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