【发布时间】:2014-12-16 00:25:05
【问题描述】:
我正在编写一个基于移动平台类固醇、angular.js 和 firebase.js 的应用程序。最近遇到这样的问题:页面没有加载,因为它试图访问一个奇怪的urlfile://file:///Users/patutinskijfedor/Desktop/firebase/WILLY/www/。
Error: Failed to execute 'replaceState' on 'History': A history state object with URL 'file://file:///Users/patutinskijfedor/Desktop/firebase/WILLY/www/' cannot be created in a document with origin 'null'.
我在 Internet 上阅读了有关此问题的信息,并意识到我的问题在于角度路由。它看起来像这样(文件app.js):
angular.module('SCBI', ['SCBI.controllers','ngRoute']).config(function($routeProvider, $locationProvider){
$locationProvider.html5Mode(true);
$routeProvider.when('/teachers',{ templateUrl: 'teachers.html'});
$routeProvider.when('/teachers/:id', {templateUrl: 't.html', controller: 'TeachersListController'});
$routeProvider.when('/', {templateUrl: 'authorization.html', controller: 'AuthorizationController'});
$routeProvider.otherwise({redirectTo:'/'});
});
所以问题可能出在html5Mode。我的问题是:如何修复app.js 中的路由?该项目的完整代码在这里:https://github.com/patut/SCBI。
【问题讨论】:
-
会不会是这个
file://file:///造成的?不应该只是file://或更好的locahost... -
您是使用 Node 来托管它还是只是在文件系统之外运行该站点?
-
能否尝试在 templateUrls 中添加 '/',例如 /teachers.html 等?
标签: angularjs html url-routing angular-routing ngroute