ember.jsember-cli

How to fill the column values from server side in Ember


I am using ember-cli. I want to create a record for a route students which has the details of students(say 'Name','Age','Marks'). I will get two values from UI('Name','Age') and I have to return a value from server side('Marks').

My code in controller of students.new is:

var newStudent = this.store.createRecord('student', { Name:'XYZ', Age: '20' });
newStudent.save();
this.transitionToRoute('students');

My code in template of 'students' is:

{{#each student in model}}
<tr>
    <td>{{student.Name}}</td>
    <td>{{student.Age}}</td>
    <td>{{student.Marks}}</td>
</td>
{{/each}}

But after saving, in students only two values that I gave in UI only came. The value I returned from server side was not updated. It is loaded only when the page is reloaded.

How can I do it without reloading the page?


Solution

  • The student model (models/student.js) should contain the marks attribute.