2016-06-12 15 views
0

Angular-Ui-Routerを使用してメタタグを管理するか、Angular-Ui-Routerを使用する方法がありますか?Meteor + Angular-Ui-Routerのメタタグ(<title>)

あなたのアプリは次のようにラップすることはできません:<html ng-app="app">、それは少なくとも<body ng-app="app">でなければなりません - MeteorはすべてのCSSとJSの依存関係を調べます。したがって、Angularアプリには<head>にアクセスする手段がありません(例:$rootScope)。

角度-UI-ルーターなしであなたは、単に(partyDetails.html)を追加することができます。

<head> 
    <title>Details of party {{}}</title> 
</head> 

をテンプレートに、UI-ルータでは動作しない、私が取得:

Error: Cannot find module './partyDetails.html' 
Error: [$injector:modulerr] Failed to instantiate module app due to: 
[$injector:nomod] Module 'app' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument. 

<head>タグを削除しても問題ありません。

私のウェブサイトでは、タグを動的に設定する必要があります(<title></title>のように!)。実際は可能ですか?

答えて

0

私はyasinuslu:blaze-metaを使用することができました。あなたのコンポーネントコントローラ:

import angular from 'angular'; 
import angularMeteor from 'angular-meteor'; 
import uiRouter from 'angular-ui-router'; 
import { Meteor } from 'meteor/meteor'; 
import { Meta } from 'meteor/yasinuslu:blaze-meta'; 

//.. 

class PartyDetailsCtrl { 
    constructor($stateParams, $scope) { 
     'ngInject'; 

     //.. 

     Meta.config({ 
      options: { 
       title: "Default Title", 
       suffix: "Socially", 
       separator: " — " 
      } 
     }) 

     Meta.set({ 
      name: 'name', 
      property: 'description', 
      content: 'Meta description' 
     }); 

     Meta.setTitle("Party Details"); 

    } 
    //.. 
} 
//.. 

私はMeta.config({})アプリの.runブロックに配置することができると信じています。希望が助けてくれる!