获取“#!/(状态)"在网址AngularJS状态中 [英] Getting "#!/(state)" in url AngularJS states
问题描述
我正在使用OAuth进行应用程序设计,因此首先要加载一个php页面以通过OAuth进行身份验证.完成后,回调php脚本将重定向到我的angular应用程序的起始页.
I'm doing an application using OAuth so first of, a php-page is loaded to authenticate with OAuth. When finished the callback php script redirects to the start page of my angular application.
// Redirect user to the startpage of the application
header("location: http://localhost/app/start.html");
在这里,Angular被实例化,所有脚本都已加载,并且状态提供程序应该在此处重定向到.otherwise状态.
Here, Angular is instantiated, all scripts are loaded and the stateprovider is supposed to redirect to the .otherwise state here.
app
.config(function($stateProvider, $urlRouterProvider){
$urlRouterProvider.otherwise('main/front');
$stateProvider
.state('main',{
url: '/main',
abstract: true,
templateUrl:'templates/menu.html'
})
.state('main.frontpage',{
url: '/front',
templateUrl:'templates/frontPage.html'
})
});
重定向正常,并且我进入正确的页面main/front,尽管我收到了一个奇怪的url,JQuery一直对此发出警报.
The redirect works fine and i'm getting to the correct page main/front though i'm getting a weird url that JQuery keeps alarming about.
jQuery错误:
未捕获的错误:语法错误,无法识别的表达式:#!/main/front
Uncaught Error: Syntax error, unrecognized expression: #!/main/front
为什么该网址获得#号!在那登录?
Why is the url getting the #! sign in there?
JQuery错误似乎在其他地方抛出.与这个问题无关.
The JQuery error appears to be thrown else where. not relevant to this question.
推荐答案
我通过以下代码解决了问题.
I got resolved with following code.
$locationProvider.hashPrefix('');
不然就去使用yeoman设置的AngularJS项目的路由问题
这篇关于获取“#!/(状态)"在网址AngularJS状态中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!