Meteor helpers not available in Angular template

空扰寡人 提交于 2019-12-24 03:30:00

问题


I am learning Meteor and I'm trying to add internationalization support with the tap:18n package. Unfortunately, the template helper function _ is not availble inside Angular modules. For example

<div>{{_ "foo"}}</div>

works, but does not when using it inside a module template :

> index.html

<div ng-app="app" ng-include="'foo.ng.html'">

> foo.ng.html

<div ng-app="bar">
  <div>{{_ "bar"}}</div>
</div>

note: app is declared inside foo.js as angular.module('app', ['angular-meteor']);, in the project root level.

Is it possible to make helpers available inside Angular modules?

(note: see referenced issue.)

** Edit **

Same thing happens when trying to render package templates inside another template :

> index.html

<section ng-app="users"
         ng-include="'users/usersession.ng.html'">
</section>

> users/usersession.ng.html

<ul class="nav navbar-nav navbar-right">
  {{> loginButtons}} <!-- here -->
</ul>

Then I get Syntax Error: Token '>' not a primary expression at column 1 of the expression [> loginButtons] starting at [> loginButtons].

Note: the module users is defined and everything works fine without the {{> loginButtons}} expression.


回答1:


You can use meteor templates inside angular. Try something like:

<meteor-include src="myTemplate"></meteor-include>

Your template would be something like:

<template name="myTemplate">
    <div>{{_ "foo"}}</div>
</template>

Remember when naming .html files, the angular templates will be name.ng.html and the meteor templates will just be name.html



来源:https://stackoverflow.com/questions/31586057/meteor-helpers-not-available-in-angular-template

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!