我希望有人可以解释我在这里做错了什么.我正在使用带有把手模板的Ember.js,我已经尝试了很多方法来获取把手#if else为我工作,但它总是返回if和else的内容..这是我正在使用的代码.
App.js:
App = Ember.Application.create({
selectedView: "Home",
IsHome: function() {
this.get('selectedView') === 'Home'
}.property('selectedView')
});
Run Code Online (Sandbox Code Playgroud)
index.html头包含:
<script type="text/x-handlebars" data-template-name="home-view">
Hello, This is the home view.
</script>
<script type="text/x-handlebars" data-template-name="edit-account">
Hello, This is the account edit view.
</script>
Run Code Online (Sandbox Code Playgroud)
在身体里:
<script type="text/x-handlebars">
{{#if App.IsHome}}
{{view HomeView}}
{{else}}
{{view editAccountView}}
{{/if}}
</script>
Run Code Online (Sandbox Code Playgroud)
这最终会在页面正文中显示两个视图.任何建议表示赞赏,
谢谢Steve