我有一个场景,我从c#中获取数据并希望在我的cshtml视图中显示它。现在问题是我的Angular文件(EditSingleRecord.js)正在检索列表。我无法在我的cshtml(EditSingleRecord.cshtml)中获取它。
/// <reference path="C:\Users\Deepak\documents\visual studio 2015\Projects\EBazar\EBazar\Scripts/angular-resource.min.js" />
(function() {
//Create a Module
var app = angular.module('MyApp', []); // Will use ['ng-Route'] when we will implement routing
//Create a Controller
app.controller('MYController', function($scope, $http) { // here $scope is used for share data between view and controller
$scope.FetchTblName = function() {
$http({
url: '/Admin/FetchTableName',
method: 'GET',
headers: {
"Content-Type": "application/x-www-form-urlencoded; charset=utf-8"
}
}).success(function(data) {
$scope.TempName = data
$scope.EditForTable();
if ($scope.TempName == 'ContactTbl') {
$('#ContactTbl').show();
$('#CourseTbl').hide();
$('#CourseDescTbl').hide();
$('#CourseSubDescTbl').hide();
$('#InternTbl').hide();
$('#LocationTbl').hide();
} else if ($scope.TempName == 'CourseTbl') {
$('#ContactTbl').hide();
$('#CourseTbl').show();
$('#CourseDescTbl').hide();
$('#CourseSubDescTbl').hide();
$('#InternTbl').hide();
$('#LocationTbl').hide();
} else if ($scope.TempName == 'CourseDescTbl') {
$('#ContactTbl').hide();
$('#CourseTbl').hide();
$('#CourseDescTbl').show();
$('#CourseSubDescTbl').hide();
$('#InternTbl').hide();
$('#LocationTbl').hide();
} else if ($scope.TempName == 'CourseSubDesc') {
$('#ContactTbl').hide();
$('#CourseTbl').hide();
$('#CourseDescTbl').hide();
$('#CourseSubDescTbl').show();
$('#InternTbl').hide();
$('#LocationTbl').hide();
} else if ($scope.TempName == 'InternTbl') {
$('#ContactTbl').hide();
$('#CourseTbl').hide();
$('#CourseDescTbl').hide();
$('#CourseSubDescTbl').hide();
$('#InternTbl').show();
$('#LocationTbl').hide();
} else if ($scope.TempName == 'LocationTbl') {
$('#ContactTbl').hide();
$('#CourseTbl').hide();
$('#CourseDescTbl').hide();
$('#CourseSubDescTbl').hide();
$('#InternTbl').hide();
$('#LocationTbl').show();
}
});
};
$scope.EditForTable = function() {
var Data = $.param({});
var MyEditTblList = [];
$http({
url: '/Admin/FetchDataForEdit',
method: 'POST',
data: Data,
headers: {
"Content-Type": "application/x-www-form-urlencoded; charset=utf-8"
}
}).success(function(data) {
$scope.MyEditTblList = data;
}).error(function(data) {
alert(data);
});
}
})
})();
<div ng-app="MyApp" ng-controller="MYController">
<div class="container">
<h2>{{TempName}} Details</h2>
<div class="table table-responsive">
<table id="LocationTbl" class="table table-hover table-bordered" style="margin:0px 5px; width:800px">
<thead>
<tr>
<td>
S. No.
</td>
<td>
Loc ID
</td>
<td>
Location Name
</td>
</tr>
</thead>
<tbody>
<tr ng-repeat="row in MyEditTblList">
<td>
{{$index+1}}
</td>
<td>
{{row.ID}}
</td>
<td>
<input type="text" class="form-control" ng-model="row.LocName" />
</td>
</tr>
</tbody>
</table>
</div>
</div>
问题是虽然MyEditTblList正在获取记录但我无法在我的cshtml上看到记录。请帮助!!