我有一些計算代碼:如何綁定大火模板與流星數據
Template.smartoptimizer.onCreated(function() {
this.currentSelector = new ReactiveVar({});
this.ready = new ReactiveVar(false);
this.length = new ReactiveVar(31.8);
this.width = new ReactiveVar(48.3);
this.height = new ReactiveVar(3.38);
this.area = new ReactiveVar((31.8 + 2*0.6)*(48.3 + 2*0.6));
this.workingSpace = new ReactiveVar(0.60);
this.slopeAngle = new ReactiveVar('1:1');
this.excSloped = function() {
let data = {};
data.areaExPit = (this.length + 2*this.workingSpace)*(this.width + 2*this.workingSpace);
data.areaTerrain = (this.length + 2*this.workingSpace + 2*this.width)*(this.width + 2*this.workingSpace + 2*this.width);
data.volumePrism = this.height/3 * (data.areaExPit + Math.sqrt(data.excSloped*data.areaTerrain) + data.areaTerrain);
data.volumeBackf = data.volumePrism - (this.height*this.length*this.width);
return data;
};
this.excVertical = function() {
let data = {};
data.areaExPit = (this.length + 2*this.workingSpace)*(this.width + 2*this.workingSpace);
data.areaTerrain = (this.length + 2*this.workingSpace)*(this.width + 2*this.workingSpace);
data.volumePrism = ((data.areaExPit*data.areaTerrain)/2) * 5;
data.volumeBackf = data.volumePrism - (this.height*this.length*this.width);
data.wallArea = this.height*(this.length + 2*this.workingSpace) + 2*(this.width + 2*this.workingSpace);
return data;
};
});
我也有calculationsData
幫手有與該計算結果的對象。 所以,我需要把這個放在我的Blaze模板中,我不知道如何。
<template name="smartoptimizer">
<div class="row">
{{#with calculationsData}}
<div class="col s4">
<h4>excavation sloped</h4>
<table class="bordered striped calculations-table" width="100%">
<tbody>
<tr>
<td>area excavation pit</td>
<td>area terrain</td>
<td>volume Prismatoid</td>
<td>volume backf.</td>
</tr>
<tr>
<td>{{excSloped.areaExPit}}</td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</div>
<div class="col s4">
<h4>excavation vertical</h4>
<table class="bordered striped calculations-table" width="100%">
<tbody>
<tr>
<td>area excavation pit</td>
<td>area terrain</td>
<td>volume Prismatoid</td>
<td>volume backf.</td>
<td>wall area</td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</div>
{{/with}}
</div>
</template>
顯示你的'calculateData'輔助代碼 – Styx