Angular / Ui-router - 头部元标签填充DOM树

时间:2016-05-26 20:22:41

标签: angularjs meta bootstrapping

任何人都可以帮助我理解为什么当我在html标签中引导角度时,每个元标记都有应用程序的DOM?我正在处理动态元标记,但这种情况只是通过引导html而不是body来存在。

或者任何人都可以验证这是正常的,不会给我一个性能问题,应该被忽略吗?

enter image description here

这里是module.config函数的开头:

angular.module('numetal')
    .config(function ($stateProvider, $urlRouterProvider, $locationProvider) {
        'use strict';

        $locationProvider.html5Mode(true);
        $locationProvider.hashPrefix('!');


        $urlRouterProvider.otherwise('/');

        $stateProvider
            .state('metal', {
                url: '',
                template: '<layout></layout>',
                abstract: true,
                controller: function (Facts) {
                    var vm = this;
                    vm.a = Facts.api;
                    vm.d = Facts.data;
                    vm.s = Facts.state;
                    vm.u = Facts.ux;
                },
                controllerAs: 'metal',
                data: function (State) {
                    return {
                        head: {
                            title: 'Forging Technology - Serving Vancouver with Superior Metalwork',
                                keywords: State.params,
                                description: "your meta description",
                                robots: "index,follow",
                                canonical: 'http://www.mySite.tld/home'
                        }
                    }
                }
            })
            .state('metal.home', {
                url: '/',
                template: '<posts></posts>',
                data: function (State) {
                    return {
                        head: {
                            title: 'Forging Technology Proudly Serving Vancouver with Superior Metalwork',
                            keywords: State.params,
                            description: "Posts from Forging Technology, Vancouver Metalwork",
                            robots: "index,follow",
                            canonical: 'http://www.mySite.tld/home'
                        }
                    }
                }
            })

谢谢大家!

0 个答案:

没有答案