我正在尝试使用内联模板获取视图,以便在有条件的车把内显示。在我的应用程序代码中,如果我导航到另一条路线然后再返回,它就会显示出来。在小提琴中,我收到有关视图的错误。
<script type="text/x-handlebars" data-template-name="application">
<h1>If you click that button, I might say 'Hello!'</h1>
<button {{action 'click_me'}}>Click me</button>
{{#if controller.new_visible}}
{{#view App.MyView}}
Hello! {{/view}}
{{/if}}
</script>
var App = Ember.Application.create();
App.MyView = Ember.View.extend({});
App.ApplicationController = Ember.Controller.extend({
new_visible: false,
actions: {
click_me: function() {
alert('You clicked me!');
this.set('new_visible',true);
}
}
});
App.ApplicationView = Ember.View.extend({
templateName: 'application'
});
App.Router = Ember.Router.extend({
root: Ember.Route.extend({
index: Ember.Route.extend({
route: '/'
})
})
});
我究竟做错了什么?