angularjs SEO友好的网址不起作用

时间:2016-10-08 09:14:31

标签: javascript angularjs express routing seo

我想让我的expressjs + angularjs SEO友好,我读了很多关于$ locationProvider的文章。我正在使用此代码,但我的应用程序无法运行并在浏览器中显示空白页面:

这是我的角度代码:

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");
});

这是输出:

enter image description here

1 个答案:

答案 0 :(得分:0)

您可能需要在html文件中插入基本标记:

$ egrep -ir "~C:/msys32" .

来源:https://stackoverflow.com/a/31098416/1005137