AngularJS routeProvider未在URL末尾添加哈希
我已配置以下routeProvider:AngularJS routeProvider未在URL末尾添加哈希,angularjs,routes,coffeescript,location-provider,Angularjs,Routes,Coffeescript,Location Provider,我已配置以下routeProvider: angular.module('myModule').config ['$routeProvider', (provider) -> provider .when '', templateUrl: '/templates/dashboard.html' .when '/some_path/:some_param', templateUrl: '/templates/dashboard.html' 以及包
angular.module('myModule').config ['$routeProvider', (provider) ->
provider
.when '',
templateUrl: '/templates/dashboard.html'
.when '/some_path/:some_param',
templateUrl: '/templates/dashboard.html'
以及包装静态服务模板中的以下内容:
我还适当地定义了模板/dashboard.html
当我导航到url时,会加载初始页面,但是url上的#
不会延迟,这会导致在使用$location.path('fooPath')
尝试在控制器中重写url时出错
特别是$location.path('fooPath')
,将URL更改为current_dashboard_path/#/
,然后重新加载,而我希望URL设置为:
current_dashboard_path/#/
,然后是位置(“fooPath”)
,将其更改为current_dashboard_path/#/fooPath
一些额外的上下文:我想使用它,这样我就可以使用$location
服务来更改url,而无需重新加载页面
问题是,当填充ng视图时,我如何强制Angular延迟
。我的routeProvider中缺少以下行:
.when '/',
templateUrl: '/templates/dashboard.html'
另外,空白路由
.when '',
templateUrl: '/templates/dashboard.html'
需要移除
在控制器中,重写URL而不重新加载页面的方法如下:
lastRoute = route.current
scope.$on('$locationChangeSuccess', (event)->
route.current = lastRoute
)
我的routeProvider中缺少以下行:
.when '/',
templateUrl: '/templates/dashboard.html'
另外,空白路由
.when '',
templateUrl: '/templates/dashboard.html'
需要移除
在控制器中,重写URL而不重新加载页面的方法如下:
lastRoute = route.current
scope.$on('$locationChangeSuccess', (event)->
route.current = lastRoute
)
您是否查看过$location.hash('value')$location.hash('value');将路径更改为当前_dashboard_path#值,而不是当前_dashboard_path/#/value,该值仍然未传递正确的路径参数。是否查看了$location.hash('value')$location.hash('value');将路径更改为当前_dashboard_path##值,而不是当前_dashboard_path/#/value,该值仍然未传递正确的路径参数。