I want to pass id from template user.hbs to controller user.js so I can bind student to a particular class.
It gives me an error: Assertion Failed: You cannot pass 'undefined' as id to the store's find method.
app/templates/user.hbs template:
<b> First name: </b> <br>
<b> Last name: </b> <br>
<select>
Liquid error: wrong number of arguments (1 for 0)
<option value=> </option>
</select>
<button > Insert student </button>
app/controllers/user.js:
import Ember from 'ember';
export default Ember.Controller.extend({
insertStudent(val){
var firstName = this.get('firstName');
var lastName = this.get('lastName');
var class2 = this.store.find('class', val);
var students = class2.get('students');
var newStudent = this.store.createRecord('student', {
firstName : firstName,
lastName: lastName,
class: class2
});
newStudent.save();
students.push(newStudent);
class2.set('students', studenti);
class2.save();
this.setProperties({
firstName: '',
lastName: ''
})
}
});
Aucun commentaire:
Enregistrer un commentaire