我有2个视图共享一个视图,我试图在它们之间传递变量来打开各种html段。这可能吗?当我运行console.log时,view.showTitle variable = "view.showTitle"
不是它应该是1吗?奇怪,对吧?
view 1调用view 2并传递param:
{{view "components/social" showTitle="1"}}
view 2尝试将此参数传递给辅助函数:
{{#variable-exists view.showTitle}}
YES
{{else}}
NO
{{/variable-exists}}
正在调用助手:
export default function(elem,options) {
if (Ember.isEmpty(elem)) {
return options.inverse(this);
} else {
return options.fn(this);
}
}
我正在使用ember cli项目来构建我的ember应用程序。
此帖发布时的当前设置:
DEBUG: -------------------------------
DEBUG: Ember : 1.5.1
DEBUG: Ember Data : 1.0.0-beta.7+canary.b45e23ba
DEBUG: Handlebars : 1.3.0
DEBUG: jQuery : 2.1.1
DEBUG: -------------------------------
答案 0 :(得分:1)
按照这两个指南a-way-to-let-users-define-custom-made-bound-if-statements和custom bound helpers,我可以调整我的共享视图,而不是标准的#if语句。这应该比在那里扔#if更安全。
<li>
<a href="{{unbound view.varProductSocialBlog}}">
{{#if-equal view.showDiv "true"}}<div>{{/if-equal}}<i class="fa fa-rss-square"></i>{{#if-equal view.showDiv "true"}}</div>{{/if-equal}}
{{#if-equal view.showTitle "true"}}Blog{{/if-equal}}
</a>
</li>
我正在使用ember cli项目来构建我的ember应用程序。
此帖发布时的当前设置:
DEBUG: -------------------------------
DEBUG: Ember : 1.5.1
DEBUG: Ember Data : 1.0.0-beta.7+canary.b45e23ba
DEBUG: Handlebars : 1.3.0
DEBUG: jQuery : 2.1.1
DEBUG: -------------------------------