lundi 23 janvier 2017

Give every angular material checkbox and ID

I am currently having a problem:

I need to create md-checkboxes from a Database. This part works fine with ng-repeat. But I am having a problem in reading those checkboxes out. Every entry in the Database has its own unique ID (I am using RethinkDB) so I though I just can apply this as ID.

md-card(ng-repeat="n in ideas")
md-card-content
span
md-checkbox(type="checkbox" id='n.id') 

I am working with Jade / Pug as View Engine. But how am I now able to read out all checkboxes at once? I tried many methods like looping through all ElementsByTagName("md-checkbox") and than with a for to read the checked value but it always returns undefined.

 const checkboxes = document.getElementsByTagName("md-checkbox");
 console.log(checkboxes) //works fine, prints all checkboxes
 for (let i = 0; i < checkboxes.length; i++) {
    console.log(checkboxes[i].checked); //returns undefined
 }

Do you have any Ideas how to read all Boxes at once?




Aucun commentaire:

Enregistrer un commentaire