【问题标题】:angular-seo doesn't render the ui-view contentangular-seo 不呈现 ui-view 内容
【发布时间】:2014-04-24 19:14:03
【问题描述】:

我正在使用 angular-seo 但它不渲染 ui-view 内容。

我的设置:

.config(function($locationProvider,$stateProvider) {
    $urlRouterProvider.otherwise('/');
    $locationProvider.html5Mode(true); 
    $stateProvider
       .state('index', {
            url: '/',
            templateUrl: 'src/app/default/site/site.tpl.html',
            controller: 'IndexCtrl'
        })
        .state('blog', {
            url: '/blog',
            templateUrl: 'src/app/default/blog/blog.tpl.html',
            resolve: {
                posts: function(Post){
                    return Post.all();
                }
            },
            controller: 'BlogIndexCtrl'
        })
})
<meta name="fragment" content="!" />
angular.module('app', ['seo']);
.controller('BlogIndexCtrl', function ($scope,posts) {
    $scope.posts =  posts;
    $scope.htmlReady();
})




phantomjs --disk-cache=no ~/vendor/angular-seo/angular-seo-server.js 5000 http://localhost

但是当我跑步时

curl 'http://localhost:3000/?_escaped_fragment_=/blog'

我只得到没有内部 ui-view 内容的 html :(

怎么了?

【问题讨论】:

    标签: angularjs seo


    【解决方案1】:

    您是否尝试将 $scope.htmlReady 放在 $viewContentLoaded 事件上?

    【讨论】:

    • 好点,但它不起作用我把它放在运行块中 $rootScope.$on('$viewContentLoaded', function(evt) { //console.log(evt); $rootScope .htmlReady(); });
    • 我不使用 angular-seo(仅用于小事),但看着 server side code 我认为它只需要 hashbang URL,它在 html5Mode 下不起作用。你可以试试不使用 html5Mode 并告诉我吗?
    • 改代码切换到#是相当困难的,但等我有时间我会试试的。感谢关心:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-07
    • 1970-01-01
    相关资源
    最近更新 更多