如何使用Angular在mvc中发布多行 [英] How do I post multiple rows in mvc using Angular
本文介绍了如何使用Angular在mvc中发布多行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我无法在单个按钮上发布多行。我没有看到Alert.Below中那些多行的值是我的HTML和脚本代码。请帮助!!!
这是我的HTML: -
I am unable to post multiple rows on single of a button. Neither I could see the values of those multiple rows in Alert.Below are my HTML and script code. Please HELP!!!
This is my HTML:-
<div ng-app="Employee">
<div ng-controller="Attendance">
<table id="example2" class="table table-bordered table-hover">
<thead>
<tr>
<th>Employee Name</th>
<th>Date</th>
<th>Status</th>
<th>Reason(if any)</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="Emp in employeeList">
<td>{{Emp.Name}}</td>
<td>
<input type="hidden" ng-model="Emp.Id" />
<input type="date" ng-model="Emp.Date" />
</td>
<td>
<select ng-model="Emp.Status">
<option ng-repeat="DDL in dropDownList">{{DDL}}</option>
</select>
</td>
<td>
<input type="text" ng-model="Emp.Reason" />
</td>
</tr>
</tbody>
</table>
</div>
</div>
<input type="submit" value="Save" ng-click="Save(Emp)" />
和我的Angular脚本:
And my Angular Script:
<script type="text/javascript">
var Employee = angular.module("Employee", []);
Employee.controller("Attendance", function ($scope, $http) {
$scope.employeeList = [];
$http({
method: "GET",
url: "/Attendance/Details",
}).success(function (data) {
$scope.employeeList = data.a;
$scope.dropDownList = data.b;
}).error(function (error) {
$scope.Message = error.Message;
})
$scope.Save = function () {
alert(JSON.stringify(Emp));
$http({
method: "Post",
url: "/Attendance/SaveAttendance1",
data: JSON.stringify(Emp),
}).success(function (data) {
alert(data);
}).error(function (err) {
$scope.Message = err.Message;
})
};
});
</script>
推荐答案
范围,
http){
scope.employeeList = [];
scope.employeeList = [];
这篇关于如何使用Angular在mvc中发布多行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文