2
Answers

Why data showing time is long using AngularJS?

ELR RLE

ELR RLE

8y
317
1
Why data showing time is long by AngularJS in MVC 4 using Razor Syntax?
 
 
In my code, loading time is long in showing data in the userList  when ng-click.
Please answer me.
 
View in MVC
 
eg
<tr ng-repeat="n in user" ng-click="GetDataybyID(n.ID,n.Name,n.Description,n.Remark)">
<td>{{n.Name}}</td>
<td>{{n.Description}}</td></tr>
 
 
<tr ng-repeat="user in userList">
<td>{{user.Employee_No}}</td>
<td>{{user.Employee_Name}}</td>
<td>{{user.Position_Name}}</td>
<td>{{user.Department_Name}}</td>
</tr> 
 
 
Method Calling using AngularJS
 
$scope.GetDataybyID = function (ID, Name, Description, Remark) {
$http.get('GetData', { params: { userId: ID } }).success(function (data) {
$scope.userList= data;
if (data.length == 0) {
}
else {
}
}).error(function () {
$scope.error = "An Error has occured while loading posts!";
});
}; 
 
 
Method in C#
 
public JsonResult GetData(int userId)
{
var empListbyID=(from e in db.tbl_Employee.AsEnumerable()
select new { e.Employee_No, e.Employee_Name, p.Position_Name, d.Department_Name}).ToList();

return Json(empListbyID, JsonRequestBehavior.AllowGet);
 
 
Answers (2)
0
ELR RLE
NA 42 2.7k 8y
I show some data of employee in Employee Lists, not detail.I must show the details data of each employee in Employee List_Details when only click Employee Lists row by EmpID.
Employee Lists
 Employee Name
 Description
 Mr Smith
 Testing1
 Ms Smith
 Testing2
 Dr Smith
 Testing3
Employee List_Details
 Employee NO
 Employee Name
 PositionDepartment
emp001
 Mr Smith
 Developer IT
 
 
The following code get the details of each employee in Employee List ng-click by passing each EmpID.
And show details data in Employee List_Details.
View in MVC
  1. Employee Lists
  2. <tr ng-repeat="e in emp" ng-click="GetDatabyUserID(u.ID)">  
  3.           <td>{{e.Name}}</td>  
  4.           <td>{{e.Description}}</td>  
  5. </tr>  
  6.   
  7.   
  8.   Employee List_Details
  9. <tr ng-repeat="emp in EmpList">  
  10.      <td>{{emp.Employee_No}}</td>  
  11.      <td>{{emp.Employee_Name}}</td>  
  12.      <td>{{emp.Position_Name}}</td>  
  13.      <td>{{emp.Department_Name}}</td>  
  14. </tr> 
Angular JS
  1. $scope.GetDatabyUserID = function (ID) {  
  2.         $http.get('GetEmployeeDetails', { params: {EmpId: ID } }).success(function (data) {  
  3.             $scope.EmpList = data;  
  4.         }).error(function () {  
  5.             $scope.error = "An Error has occured while loading posts!";  
  6.         });  
  7.    }; 
 
C# Method
  1. [HttpGet]  
  2.  [Authorize]  
  3.  public JsonResult GetEmployeeDetails(int EmpId)  
  4. {  
  5.       var empListByEmpID= (from e in db.tbl_Employee.AsEnumerable()  
  6.                                  join p in db.tbl_Position on e.Position_ID equals p.Position_ID  
  7.                                  join d in db.tbl_Department on e.Department_ID equals d.Department_ID  
  8.                                  where e.EmpID== UserId  
  9.                                  orderby e.Employee_No  
  10.                                  select new { e.Employee_No, e.Employee_Name, p.Position_Name, d.Department_Name}).ToList();                                            
  11.       return Json(empListByEmpID, JsonRequestBehavior.AllowGet);  

 
 
 
 
 
0
Bikesh Srivastava
NA 19.8k 835.1k 8y
Hi,
   Can you exaplain your query ?