簡単に説明します。Meteor用のMeteor_angularjsパッケージを使用せずに、Meteor+ BladeでAngularJsを使用しています。ブレードはサーバーでページの本文を作成し、クライアントでAngularを手動でブートストラップします。
BladeにはテンプレートファイルがありTemplate['template_name']
、クライアントで簡単にレンダリングできます。私は次のようなことをしたいと思います:
div(ng-include='content.blade')
// HTML => <div ng-include='content.blade'></div>
そしてどういうわけかそれを機能させます。
互換性を維持し、新しいディレクティブを作成しないために、Angularが静的テンプレートに対して行うXHRリクエストをインターセプトし、条件を追加することが可能であると考えました。
if(URI ends with '.blade') then
name <- strip '.blade' in URI
return Template[name]()
そのテンプレートのコンパイル済みHTMLを返す必要があります。
更新:
偶然にも$ templateCacheに遭遇しましたが、今ではそれが道だと思います。
流星と角度の統合に使用する「ngMeteor」モジュールを作成しました。
angular.module 'ngMeteor',[], ->
throw 'Meteor object undefined.' unless Meteor? # Is it fine to put here?
angular.module('ngMeteor.blade',['ngMeteor']).
run ($templateCache) ->
$templateCache.put "#{name}.blade", render() for own name, render of Template
私のアプリでは:
angular.element(document).ready ->
angular.bootstrap document, ['app']
app = angular.module 'app', ['ngMeteor.blade'], ->
app.controller 'mainCtrl', ($scope,$templateCache) ->
$scope.content = $templateCache.get "content.blade" # Works!!
ブレード(body.blade):
#main(ng-controller='mainCtrl') {{ content }}
これで機能します。$templateCacheを挿入し、その名前でテンプレートを取得した後、コントローラーからレンダリングされたテンプレートを取得できますが、ng-include
それでも機能しません。