Angularjs 如何修复应用程序中的angular.js路由?
我正在移动平台类固醇、angular.js和firebase.js上编写一个应用程序。最近我遇到了这样的问题:页面无法加载,因为它试图访问一个奇怪的urlAngularjs 如何修复应用程序中的angular.js路由?,angularjs,html,url-routing,angular-routing,ngroute,Angularjs,Html,Url Routing,Angular Routing,Ngroute,我正在移动平台类固醇、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
file://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'.
我在互联网上读到了这个问题,并意识到我的问题是角度路由。它看起来像这样(文件app.js
):
因此问题可能出在
HTML5模式上。我的问题是:如何在app.js
中修复路由?项目的完整代码如下: 如果HTML5页面中提到的基本URL不正确,则可能发生这种情况。
请在此处共享您的基本URL 这可能是由该file://file:///
?不应该存在简单的file://
或更好的locahost
…您是使用Node来托管此站点,还是只是在文件系统之外运行站点?看起来类似于您是否可以尝试将“/”添加到模板URL,如/teachers.html等。?
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:'/'});
});