这是我的 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斌在这里
我添加了很多不必要的代码,以便尝试让员工模板在员工模板的出口中呈现(例如,命名出口,定义 renderTemplate 方法......),但它似乎不起作用。
我在这里做错了什么?