【发布时间】:2016-03-20 19:49:23
【问题描述】:
我希望能够单击表格中的 ng-repeat 行并从行数据中填充表单。我的 editplayer() 函数中需要什么?
这是表格和表格
<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>
【问题讨论】:
-
你的控制器在哪里?这就是你定义
editPlayer、players等的地方...
标签: javascript angularjs firebase-realtime-database