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
我正在学习《流星》,我正在尝试用tap来增加国际化支持:18n包。不幸的是,模板辅助函数_无法在角模块中使用。例如
<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.
注意:app是在foo中声明的。js角。模块('app', ['angular-流星']);
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]
.
然后我得到语法错误:从[> loginButtons]开始,令牌'>'不是表达式第1列的主表达式[> loginButtons]。
Note: the module users
is defined and everything works fine without the {{> loginButtons}}
expression.
注意:定义了模块用户,没有了{{> loginButtons}表达式,所有的操作都很正常。
1 个解决方案
#1
2
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
记住在命名.html文件时,角模板将是name.ng。html和流星模板将只是命名。html
#1
2
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
记住在命名.html文件时,角模板将是name.ng。html和流星模板将只是命名。html