什么是在页面加载时为emberjs应用程序引导数据的最佳方法.我知道它很可能从数据属性或隐藏div中的数据中获取数据,但是在emberjs应用程序生命周期中这将会是什么?
我有一个路由器,每个路由(和路由对象)都有相应的模板.我希望能够独立于其父模板显示每个模板,这意味着我不希望嵌套路由呈现给父模板的插座.基本上为每个嵌套路由创建一个单独的"页面".
App.Router.map(function() {
this.resource('recipes', function() {
this.route('new');
this.route('show', { path: '/:recipe_id' });
});
});
Run Code Online (Sandbox Code Playgroud)
我正在使用ember1.0.0-rc1
谢谢
我正在制作一个玩具应用程序来学习余烬.我有属于风格的食谱.样式只包含name属性(以及隐式id).我在新模板中设置选择字段时遇到问题,无法选择配方的样式.
这是我目前的路线,控制器和模板:
路线:
App.RecipesNewRoute = Ember.Route.extend({
model: function() {
return App.Recipe.createRecord({
title: '',
description: '',
instructions: ''
});
},
setupController: function(controller, model) {
controller.set('content', model);
}
});
Run Code Online (Sandbox Code Playgroud)
控制器:
App.RecipesController = Ember.ArrayController.extend({});
App.RecipesNewController = Ember.ObjectController.extend({
create: function() {
this.transitionToRoute('recipes.show', this.content);
},
cancel: function() {
this.content.deleteRecord();
this.transitionToRoute('recipes.index');
},
buttonTitle: 'Add Beer Recipe'
});
Run Code Online (Sandbox Code Playgroud)
模板:
食谱/新的和形式部分:
<script type="text/x-handlebars" data-template-name="recipes/new">
{{ partial 'recipes/form' }}
</script>
<script type="text/x-handlebars" data-template-name="recipes/_form">
{{ title }}
<form>
<fieldset>
<div>
<label {{bindAttr for="titleField.elementId"}}>Title</label>
{{view Ember.TextField valueBinding='title' name='title' viewName='titleField'}}
</div>
<div> …Run Code Online (Sandbox Code Playgroud)