dimanche 20 décembre 2015

ember how to add multiple models

I have one model eg 'reader' and I want to add multiple 'books' model to this object.

reader model defined books field like this:

bookss: DS.hasMany('book', {async: true}), 

when i create reader I want to add some book models to it. in template, I can list books like this:

{{#each books as |book index|}}
    {{book.name}}, {{index}} <br>
{{/each}}

<button {{action 'addReader'}}>add</button><br>

how can I pass books to 'addReader' function?




Aucun commentaire:

Enregistrer un commentaire