angularJS中页面跳转问题?

angularJS中使用“$window.location.href ”页面跳转,控制台跳出“TypeError: Cannot set property 'href' of undefined”错误,怎么解决?

阅读 5.3k
3 个回答

window.location.href不需要加$

把$window模块注入进来。

使用$location服务
1,在控制器里面注入此服务
2,使用$location.url( .....),里面填写地址

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题