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

查看:21
本文介绍了使用 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天全站免登陆