在角模板不可用流星助手不可用、流星、助手、模板

2023-09-13 05:20:22 作者:执着 Paranoid

我学习流星,然后我想补充的国际化支持挖掘:18n内包。不幸的是,模板辅助函数 _ 是没有棱角的模块里面availble的。例如:

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 :

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

> foo.ng.html

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

注意: 应用声明在 foo.js angular.module('应用',['角流星']); ,在项目的根级

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?

(注:参见参考问题)

同样的事情发生:

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

>用户/ usersession.ng.html

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

然后我得到语法错误:令牌'&GT;'不是主要的前$的前pression [的制造&gt 1 P列$ pssion; loginButtons]在[&GT开始; loginButtons]

注意:模块用户定义,一切工作正常,而不 {{&GT; loginButtons}} 前pression。

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

推荐答案

您可以使用里面的流星模板角。尝试是这样的:

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

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

您的模板会是这样的:

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

记住命名.html文件时,角模板将name.ng.html和流星模板将只是name.html

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