Ich möchte in der Lage sein, auf eine ng-repeated-Zeile in einer Tabelle zu klicken und ein Formular aus den Zeilen-Daten zu füllen. Was muss ich in meiner editplayer() Funktion haben?Wie kann ich ein Formular aus einem ng-Repeat-Element ausfüllen?
Heres der Tisch und die Form
<table class="table table-condensed table-striped table-responsive">
<thead>
<th></th>
<th>Name</th>
<th></th>
<th></th>
<th></th>
<th></th>
</thead>
<tbody>
<tr ng-repeat="player in players" ng-model="players">
<td><input type="checkbox" name="" id=""></td>
<td ng-click="editPlayer($index)">{{ player.name }}</td>
<td><i class="fa fa-paper-plane"></i></td>
<td><i class="fa fa-comment"></i></td>
<td><i class="fa fa-phone"></i></td>
<td><i class="fa fa-edit"></i></td>
</tr>
</tbody>
</table>
<form id="playerForm" name="playerForm" ng-model="thisplayer" novalidate>
<input type="text" id="id" name="id" placeholder="id" class="form-control" ng-model="player.id" ></input>
<div class="form-group">
<input type="text" id="player" name="name" required placeholder="Name" class="form-control" ng-model="player.name" ng-required="true" >{{ player.name }}</input>
<span ng-show="playerForm.name.$touched && playerForm.newplayer.name.$invalid">The name is required.</span>
</div>
<div class="form-group">
<input type="email" id="email" required Placeholder="Email" class="form-control" ng-model="player.email">{{ player.email }} </input>
</div>
<div class="form-group">
<input type="text" id="tel" required Placeholder="Tel" class="form-control" ng-model="player.tel">{{ player.tel }}</input>
</div>
<div class="form-group">
<input type="text" id="initials" required Placeholder="Initials" class="form-control" ng-model="player.initials">{{ player.initials }}</input>
</div>
<div class="form-group">
<button id="btnPlayerAdd" name="btnPlayerAdd" class="btn btn-success" type="submit" ng-click="addPlayer($event)" ng-show="!isUpdate">Add player</button>
<button id="btnPlayerSave" name="btnPlayerSave" class="btn btn-success" type="submit" ng-click="updatePlayer($event)" ng-show="isUpdate">Update player</button>
</div>
</form>
Wo ist Ihr Controller? Dort würden Sie 'editPlayer',' players', etc ... definieren. – iambriansreed