<p style="width: 450px;float: left;margin-left: 50px">
<table>
<!-- 这里以name为排序标准 -->
<tr ng-repeat="x in users | orderBy : 'name'">
<!-- $index显示序列号,从1开始 -->
<td>{{ $index + 1 }}</td>
<td>{{ x.id }}</td>
<!-- 把英文转为大写 -->
<td>{{ x.name |uppercase }}</td>
<td>{{ x.password }}</td>
<td>{{ x.email }}</td>
<td><input type="button" value="编辑" onclick="editUser()"/></td>
<td><input type="button" value="删除" onclick="deleteUser(x.id)"/></td>
</tr>
</table>
How to get the id here
onclick="deleteUser(x.id)"
This won't work, and adding {{}} won't work either.
It was a bit confusing just opening angularjs....
After obtaining, how to call the controller method?
This is a method in the controller, so calling it like this doesn’t seem to work...
function deleteUser(userID) {
alert(userID);
}
Why use the native one
onclick
?你应该用angular 的ng-click
ahResolved:
Use ng-click to call.
The calling function is:
$scope.deleteUser = function (userID) {