此处为超级编码 n00b。我正在尝试在 emberjs 中创建一个营养计算器。如果我有如下用户输入表单,我在哪里编写计算函数以及如何显示答案?
<form>
<div class="form-group">
<label for="weight">Weight</label>
{{input type="text" id="weight" class="form-control" value=weight}}
</div>
<div class="form-group">
<label for="runduration">How long will you be running? (hours)</label>
{{input type="text" id="runduration" class="form-control" value=runduration}}
</div>
<div class="form-group">
<label for="cycleduration">How long will you be cycling?</label>
{{input type="text" id="cycleduration" class="form-control" value=cycleduration}}
</div>
<button {{action calculate}}>Calculate nutrition</button>
</form>
我会在控制器中编写函数吗?
在我的路由器中,我有以下内容,但我宁愿将输入表单和显示的计算保留在同一个模板 Nutritioncalc.hbs 上
this.route('nutritioncalc');
this.resource('new-nutritioncalc', { path: '/nutritioncalc/new' });
谢谢。