Ruby on rails Angular应用程序始终重定向到默认值
我正在构建一个新的Rails API/Angular应用程序。我有两个基本页面,一个是Gulp生成的默认页面。我对这些重定向有点迷茫 如果我键入以下内容: 浏览器将在此地址重定向主页。请注意哈希: 当我打字时: 然后浏览器也会重定向主页,并在浏览器中使用以下地址:Ruby on rails Angular应用程序始终重定向到默认值,ruby-on-rails,angularjs,gulp,route-provider,Ruby On Rails,Angularjs,Gulp,Route Provider,我正在构建一个新的Rails API/Angular应用程序。我有两个基本页面,一个是Gulp生成的默认页面。我对这些重定向有点迷茫 如果我键入以下内容: 浏览器将在此地址重定向主页。请注意哈希: 当我打字时: 然后浏览器也会重定向主页,并在浏览器中使用以下地址: 添加$locationProvider并将html5Mode设置为true works,但不确定原因 'use strict'; angular.module('myapp', ['ngAnimate', 'ngCookies',
添加$locationProvider并将html5Mode设置为true works,但不确定原因
'use strict';
angular.module('myapp', ['ngAnimate', 'ngCookies', 'ngTouch', 'ngSanitize', 'ngRoute', 'ui.bootstrap'])
.config(function ($routeProvider,$locationProvider) {
$locationProvider.html5Mode(true);
$routeProvider
.when('/main', {
templateUrl: 'app/main/main.html',
controller: 'MainCtrl'
})
.when('/sentences', {
templateUrl: 'app/sentences/sentences.html',
controller: 'SentencesCtrl'
})
.otherwise({
redirectTo: '/main'
});
})
;
我还需要在index.html中添加一个基本标记
<base href="/">
任何关于为什么需要这样做的明确解释都将成为公认的答案。相关问题:和有趣的帖子:
<base href="/">