我在解決ng-repeat指令時遇到了問題,因爲我是初學者,無法自行解決它。無法迭代
var myModule = angular.module("myFirst",[]);
myModule.controller("cont", function($scope){
var employees = [
{name: "Manju", age :"23", rank:"2"},
{name: "SivaSankari", age :"23", rank:"1"},
{name: "Gayathri", age :"23", rank:"1"},
];
$scope.employees = employees;
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<html ng-app="myFirst">
<head>
<title> My workout|ngRepeat
</head>
<body>
<div ng-controller="cont">
<table>
<thead>
<th>Name</th>
<th>Age</th>
<th>Postions</th>
</thead>
<tbody>
<tr ng-repeat="x in employees">
<td>{{employees.name}}</td>
<td>{{employees.age}}</td>
<td>{{employees.position}}</td>
</tr>
</tbody>
</table>
</div>
</body>
<html>
我也有懷疑是X鍵。可以給任何關鍵值嗎? 任何人都可以幫助我解決和理解? 謝謝。
你應該寫爲'{{x.name}}''不是員工。姓名' –