我想让我的 expressjs + angularjs SEO 友好,我阅读了很多关于 $locationProvider 的文章。我正在使用此代码,但我的应用程序无法运行并在浏览器中显示空白页面:
这是我的 Angular 代码:
var myApp = angular.module("PlannerApp" , ['ngRoute' , 'appControllers' , 'ngAnimate']);
var appControllers = angular.module('appControllers' , []);
myApp.config(['$routeProvider' , '$locationProvider' , function($routeProvider , $routeProvider){
$routeProvider.
when("/home" ,
{templateUrl : "../home.html",
controller: 'HomepageCtrl'
}).
when("/about" ,
{templateUrl : "../about.html",
controller: 'AboutpageCtrl'
}).
otherwise({templateUrl : "../home.html"});
$locationProvider.html5Mode(true);
$locationProvider.hashPrefix('!');
}]);
function HomepageCtrl($scope) {
$scope.$parent.seo = {
pageTitle : 'home',
pageDescripton: 'home We are a content heavy website so we need to be indexed.'
};
}
function AboutpageCtrl($scope) {
$scope.$parent.seo = {
pageTitle : 'aboute ',
pageDescripton: 'aboute We are a content heavy website so we need to be indexed.'
};
}
myApp.run(function(){
console.log("runde");
});
这是输出:
最佳答案
您可能需要在您的 html 文件中插入一个基本标签:
<head>
<base href="/">
</head>
关于javascript - angularjs SEO 友好的 url 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39930668/