如何查看手柄模板中的所有可用变量 [英] How to see all available variables in handlebars template
问题描述
有一个相关的问题,但是你必须知道在范围内使用它:
如何在Handlebars模板中添加console.log()JavaScript逻辑?
如何输出 所有 变量?
一个好的选择是调试this的值使用Handlebars助手的模板:
1。
{{each each}}
{{log这个}}
{{/ each}}
或
2。类似于@watson建议
{{每个}}
{{debugger}}
{ / each}}
然后在D中钻取本地范围变量ev工具
或者3.您可以直接从Controller init方法内记录事项,例如:
App.UsersController = Ember.ArrayController.extend({
init:function(){
console.log(this);
console.log(this.getProperties('。'));
}
});
I'm working on my first Ember.js app and am having some trouble connecting all the dots. It would be really helpful if I could just see all the variables available within a given handlebars template.
There is a related question, but you have to know the variable that is in scope to use it: How do I add console.log() JavaScript logic inside of a Handlebars template?
How can I output all the variables?
a good option is to debug the value of 'this' in a template using the Handlebars helpers: 1.
{{#each}}
{{log this}}
{{/each}}
or, 2. similar to @watson suggested
{{#each}}
{{debugger}}
{{/each}}
and then drill in to the Local Scope Variables for 'this' in the Dev Tools
or alternatively, 3. you could log things directly from inside your Controller init method, such as:
App.UsersController = Ember.ArrayController.extend({
init: function() {
console.log(this);
console.log(this.getProperties('.'));
}
});
这篇关于如何查看手柄模板中的所有可用变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!