我有一个问题,我想添加到此表一个添加和删除按钮 但我不知道如何将数据从html发送到json数组内控制器。AngularJS - 发送一个变量从html到控制器
This is a screenshot of the app now
的HTML代码:
<table>
<div class="search">
<label>search student </label>
<input type="text" ng-model="search_query">
<label>search student </label>
<select ng-model="order_query">
<option value="id">id</option>
<option value="name">name</option>
<option value="data">data</option>
<option value="grade">grade</option>
<option value="subject">subject</option>
</select>
reverse <input type="checkbox" ng-model="reverse_query" value="reverse">
</div>
<tr>
<th>student id</th>
<th>student name</th>
<th>student data</th>
<th>student grade</th>
<th>student subject</th>
</tr>
<tr ng-repeat="item in student | filter:search_query | orderBy:order_query:reverse_query">
<td>{{ item.id }}</td>
<td>{{ item.name }}</td>
<td>{{ item.data }}</td>
<td>{{ item.grade }}</td>
<td>{{ item.subject }}</td>
</tr>
</table>
的angularjs代码:
function ListCtrl($scope)
{
$scope.student = json;
}
并且json代码:
var json = [
{
id:"123",
name:"oz",
data:"best student",
grade:"100",
subject:"computer science"
},
{
id:"1234",
name:"avi",
data:"only student",
grade:"80",
subject:"computer science"
},
{
id:"1235",
name:"matan",
data:"good student",
grade:"90",
subject:"computer science"
},
{
id:"123",
name:"oz",
data:"best student",
grade:"95",
subject:"computer science"
},
{
id:"123",
name:"oz",
data:"best student",
grade:"80",
subject:"computer science"
},
{
id:"123",
name:"oz",
data:"best student",
grade:"50",
subject:"computer science"
}
];
?请清楚你的问题 – Aravind