i have code:
<ul ng-repeat="codes in response"> <li ng-if="((codes.branch == formdata.branches.alias) && (codes.taken == 0))"> <strong>{{codes.id}}</strong> {{codes.code}} </li> </ul>
this checks if code taken database. otherwise, displayed here. want randomize codes not yet taken , pick 1 of randomize codes , assign variable pass form data store in row along registered user's information. how pass values ng-repeat pass form database?
here's conceptual answer:
- in every ng-repeat loop, check if code not taken. if not taken, push array untakencodes
- at end of loop, have list of untaken codes in array.
- when form submit happens, use code @ random (use javascript's math function pick out 1 code within index bounds of untakencodes array), , push db.
math.floor((math.random() * upperbound) + lowerbound);
where upperbound array length , lowerbound 0
Comments
Post a Comment