在处理,我被困在约$ locationProvider问题。我有一个简单的单页页面。但我发现了以下错误:
been dealing with some $locationProvider issues that I am stuck on. I've got a simple single page page. But I'm getting the following error:
TypeError: Cannot read property 'replace' of undefined
at trimEmptyHash (angular.js:10551)
at Object.$locationWatch (angular.js:11399)
at Scope.$get.Scope.$digest (angular.js:14217)
at Scope.$get.Scope.$apply (angular.js:14488)
at bootstrapApply (angular.js:1449)
at Object.invoke (angular.js:4182)
at doBootstrap (angular.js:1447)
at bootstrap (angular.js:1467)
at angularInit (angular.js:1361)
at HTMLDocument.<anonymous> (angular.js:26065)
我的app.js文件是pretty简单...
My app.js file is pretty simple...
var app = angular.module('app',
[
'ui.router'
]
);
app.config([
'$stateProvider',
'$httpProvider',
'$locationProvider',
'$urlRouterProvider',
function ($stateProvider, $httpProvider, $locationProvider, $urlRouterProvider) {
$locationProvider.hashPrefix('!');
$locationProvider.html5Mode(true);
$stateProvider
.state('home',
{
url: '/',
views: {
'aboutView':
{
template: function (params) {
console.log("home");
return 'home';
}
}
}
})
.state('about',
{
url: '/about',
views: {
'aboutView':
{
template: function (params) {
console.log('about')
return 'about';
}
}
}
})
;
}
]);
我确实有&LT;基地HREF =HTTP://本地主机/应用/ uiv8 //&GT;
在我的index.html文件设置。所以,当我注释掉$ locationProvider code,一切工作在#模式下的罚款。我能到/#/约等没有问题。当我把$ locationProvider件返还的,什么都没有。
I do have the <base href="http://localhost/apps/uiv8/" />
set in my index.html file. So, when I comment out the $locationProvider code, everything works fine in # mode. I can get to /#/about, etc. without issue. As soon as I put the $locationProvider parts back in, nothing.
多一点点关于我的环境....我们有asp.net的MVC在这里,和route.config正在做{* URL}所有重定向到默认路由,而且我竟然不见了至于与URL修改IIS重写发送到默认,但我仍然得到上面的分析错误。
A little bit more about my environment.... We do have asp.net's MVC in here, and the route.config is doing a {*url} to redirect all to the default route, and I've even gone as far as modifying IIS with url rewrites to send to the default, but I still get the parse Error above.
所以,任何人都得到了什么回事任何想法?
So, anybody got any ideas what's going on?
谢谢,尼克
在您的索引页将基准标记,如:
Add the base tag in your index page like :
<base href="/">
而不是:
<base href="http://localhost/apps/uiv8/" />
希望这本书能解决你的问题。
Hope it will solve your problem.
上一篇:调用javascript函数的范围之外的NG-点击函数、范围、javascript、NG
下一篇:这是什么错误:[$喷油器:unpr]未知提供商:tProvider&LT; - T&LT; - myActiveLinkDirective是什么意思?喷油器、提供商、错误、这是什么