mysql - How do you assign a value from ng-repeat in AngularJS? -


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:

  1. in every ng-repeat loop, check if code not taken. if not taken, push array untakencodes
  2. at end of loop, have list of untaken codes in array.
  3. 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