Hi,
is there any way to pass a promise not yet fullfilled from a template to an helper?
Hi,
is there any way to pass a promise not yet fullfilled from a template to an helper?
What kind of Promise is it? What is the helper doing?
In the route i return multiple models with RSVP.hash() function. i would like to pass one of these models to an helper from the template. The promise seems to be unsolved if I use the helper. If i use a simple #each everything works.
The helper should print a select of each value of the model in a
The route will wait on all of the models inside the RSVP.hash to be resolved before rendering the template, so something else might be going on? ![]()
You can try this https://github.com/fivetanley/ember-promise-helpers …
the route wait until all models has to be resolved, but in my template if i call an Helper and i try to pass as a parameter one of the models inside the RSVP.hash it seems that is still trying to getting. if I print the model inside the Helper the result is:
Object { __ember1501508259365: “ember555”, store: Object, _internalModel: Object, id: Getter, currentState: Object, isError: false, adapterError: null, OVERRIDE_OWNER [id=__ember1501508259365702189462658]: Object, _super: ROOT(), validationsMixinCount: 5 }
You need to provide us with the relevant bits of your code.
this is my route
report.js
export default Ember.Route.extend({
model(){ var store = this.get(‘store’);
return store.findAll('report').then(
function(record){
var temp = record.objectAt(0);
return Ember.RSVP.hash({
reports: temp == undefined ? store.createRecord('report') : temp,
outcomes: store.findAll('outcome'),
seriousness: store.findAll('seriousness')
})
}
);
} });
patient.hbs
{{radio-button-group model.reports.patient_age_group "patient_age_group" model.reports}}helper
export function radioButtonGroup([value, name, modello]) {
let arr = lista;
var out = ``;
if (name == 'patient_age_group') {
for(var i=0; i<arr.length; i++) {
out += `<label class="vertical col-6">` +
`<input type="radio" name="`+ name +`" value="` +
arr[i].valore + `"` + (arr[i].valore==value ? ` checked="checked"`: ``) +
`> `+ arr[i].nome + `<p>` + arr[i].descrizione + `</p></label>`;
In the template i pass the last parameter ‘model.reports’ that is one of the promises of the RSVP.hash, but in the helper if try to log in console that i see the result that i pasted above. I’m sure that the promises of RSVP.hash are fulfilled. Hope you can understand now!
With Ember Data the records aren’t plain JavaScript object, so printing them always shows a complex output. What you saw printed was an Ember Data Record, not a Promise
Try print modello.get('patient_age_group') and see what you get. You need to use .get on the model to retrieve properties as this is how all the relationship matching works