以下是我的HTML模板:
<script type="text/x-handlebars">
<p>Application template</p>
{{#linkTo employees}}<button>Show employees</button>{{/linkTo}}
{{outlet}}
</script>
<script type="text/x-handlebars" data-template-name="employees">
<p>Employees template</p>
{{#linkTo employees.employee}}<button>Show employee</button>{{/linkTo}}
{{outlet employeeOutlet}}
</script>
<script type="text/x-handlebars" data-template-name="employee">
<p>Employee template</p>
</script>
这是javascript:
App = Ember.Application.create();
App.Router.map(function () {
this.resource('employees', function () {
this.route('employee');
});
});
App.EmployeeRoute = Ember.Route.extend({
renderTemplate: function() {
this.render('employee', { // the template to render
into: 'employees', // the template to render into
outlet: 'employeeOutlet', // the name of the outlet in that template
controller: 'employee' // the controller to use for the template
});
}
});
JS Bin here
我添加了许多不必要的代码,以便尝试让员工模板在员工模板的插座中呈现(例如,命名插座,定义renderTemplate方法......),但它似乎没有上班。
我在这里做错了什么?