使用yeoman设置的AngularJS项目的路由问题 [英] Routing issue with AngularJS project using yeoman setup

查看:103
本文介绍了使用yeoman设置的AngularJS项目的路由问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用yeoman建立了一个新的Angular项目。 Angular版本是1.6.0。项目设置成功,但是我遇到了路由问题

I have setup a new Angular project using yeoman. Angular version is 1.6.0. Project setup was successful but I have been facing an issue with routing

任务运行器-Grunt

Task runner - Grunt

我运行时在本地我的本地页面中的项目将使用URL

When I run the project in local my local page will load with URL

http:// localhost:9000 /#!/

我期望 http:// localhost:9000 /#/

当单击关于链接时,浏览器将路由到

When clicked on About link browser is routed to

http:// localhost:9000 /#!/%23 %2Fabout

期望: http:/ / localhost:9000 /#/ about

当我单击家庭链接时,浏览器被路由到

When I click home link browser is routed to

http:// localhost:9000 /#!/%23%2F

期望: http:// localhost:9000 /#/

可能是什么问题?我在使用AngularJS 1.5.8的其他系统中没有此类问题。

What might be the issue? I have no such issues in my other system where I'm using AngularJS 1.5.8.

推荐答案

我用以下代码解决了您可以在您的app.js文件中编写

I got resolved with following code.You can write in your app.js file

 $locationProvider.hashPrefix('');

这篇关于使用yeoman设置的AngularJS项目的路由问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆