在依赖于其他模型时创建模型

时间:2015-12-03 02:25:51

标签: javascript ember.js ember-data

当我回到路线3模型时,我对如何在createRecord动作中创建事件感到有点困惑:

return RSVP.hash({
  event: this.store.createRecord('event'),
  hiws: this.store.findAll('hiw'),
  tips: this.store.findAll('tip')
});

Event是我想创建的内容,但我在eachhiwstips hbs中创建event,因为hiw tip 1}}有一个<select class="tables__sidebar-select"> {{#each model.tips as |tip|}} <option class="tables__sidebar-option">{{tip.name}}</option> {{/each}} <select> 和一个hiws ......就像这样:

createRecord

let hiws = this.get('model.hiws'); let tips = this.get('model.tips'); let notify = this.get('notify'); let event = this.get('store').createRecord('event', { hiws: hiws, tips: tips }); event.save() 相同。 我这样想: 在我的hiw行动中:

tip

我正在尝试创建一个包含hiwtip所有属性的事件,但选择{{view "select" content=models.tips.names value=models.event.tip}} `def variables(self): #This Function gets the initial conditions from the UI pressure1=self.ui.pressure1.value pressure2=self.ui.pressure2.value temp1=self.ui.temp1.value temp2=self.ui.temp2.value ` def properties(self): #This Function pulls values from array, when user picks the gas. if self.ui.gas_2.findText('Oxygen'): rc=elementsMap['Oxygen'][1] gamma=elementsMap['Oxygen'][0] elif self.ui.gas_2.findText('Helium'): rc=elementsMap['Helium'][1] gamma=elementsMap['Helium'][0] elif self.ui.gas_2.findText('Hydrogen'): rc=elementsMap['Hydrogen'][1] gamma=elementsMap['Hydrogen'][0] def instanous(self): # This function calculates the instanous density. rho2=self.variables(pressure2)/(self.properties(rc)*self.variables(temp2)) NameError: name 'pressure2' is not defined

编辑:

现在,我正在尝试:

     val massData1 = [map(float,i) for i in massData]

但没有成功。

1 个答案:

答案 0 :(得分:0)

以下是如何实现您想要做的事情的示例: https://ember-twiddle.com/78b6a5ea8e8e84e5b2a3