Riddhi Valecha

Riddhi Valecha

  • 443
  • 3.3k
  • 413k

Angular Controller - Angular Not Defined

Mar 3 2021 6:18 PM
Dear Team,
 
I have a MVC Application, in which I have got the data in datatable.
 
I have created a view, and also made Angular Controller file.
 
I have debugged the code, I am getting the data in datatable, but I am not able to display it in view.
 
My View Code -
  1. @{  
  2. ViewBag.Title = "PendingAssets";  
  3. }  
  4. <style>  
  5. .tableData {  
  6. border-left: solid 1px #D8C3C3;  
  7. border-top: solid 1px #D8C3C3;  
  8. }  
  9. .tableData tr {  
  10. }  
  11. .tableData td, .tableData th {  
  12. border-right: solid 1px #D8C3C3;  
  13. border-bottom: solid 1px #D8C3C3;  
  14. text-align: left;  
  15. padding: 5px;  
  16. }  
  17. .tableData td {  
  18. }  
  19. .tableData th {  
  20. background-color: #FAFAFA;  
  21. padding: 7px 5px;  
  22. border-bottom-color: #9C9C9C;  
  23. }  
  24. .odd {  
  25. background-color: #f3f3f3;  
  26. }  
  27. .even {  
  28. background-color: #ffffff;  
  29. }  
  30. </style>  
  31. <h2>PendingAssets</h2>  
  32. <div ng-controller="pendingassetscontroller">  
  33. <table class="tableData" width="80%" border="0" cellpadding="0" cellspacing="0">  
  34. <tr>  
  35. <th>Computer.ComputerType</th>  
  36. <th>Model.Brand.Name</th>  
  37. <th>Model.Name</th>  
  38. <th>Computer.TcpIpHostName</th>  
  39. <th>Asset.SerialNo</th>  
  40. <th>User.UserName</th>  
  41. <th>RIL_Inventoried_User.UserName</th>  
  42. <th>Asset.Field1</th>  
  43. </tr>  
  44. <tr ng-repeat="e in PendingAssets" ng-class-odd="'odd'" ng-class-even="'even'">  
  45. <td>{{e.ComputerComputerType}}</td>  
  46. <td>{{e.ModelBrandName}} </td>  
  47. <td>{{e.ModelName'}}</td>  
  48. <td>{{e.ComputerTcpIpHostName}}</td>  
  49. <td>{{e.AssetSerialNo}}</td>  
  50. <td>{{e.UserUserName}}</td>  
  51. <td>{{e.RIL_Inventoried_UserUserName}}</td>  
  52. <td>{{e.AssetField1}}</td>  
  53. </tr>  
  54. </table>  
  55. </div>  
  56. @section scripts{  
  57. <script src="~/Scripts/AngularController/pendingassetscontroller.js"></script>  
  58. }  
pendingassetscontroller.js Code -
  1. //(function () {  
  2. // 'use strict';  
  3. var app = angular.module('myApp', [])//'MyApp') // extending from previously created angular module in the First Part  
  4. .controller('pendingassetscontroller'function ($scope, PendingAssetsService) { // explained in Part 2 about controller  
  5. $scope.PendingAssetsSrc = null;  
  6. PendingAssetsService.GetPendingAssetsList().then(function (d) {  
  7. $scope.PendingAssetsSrc = d.data; //Success callback  
  8. }, function (error) {  
  9. alert('Error!'); // Failed Callback  
  10. });  
  11. })  
  12. .factory('PendingAssetsService'function ($http) { // I have explained about factory in the Part 2  
  13. var fac = {};  
  14. fac.GetPendingAssetsList = function () {  
  15. return $http.get('/PendingAssets/GetPendingAssetsList')  
  16. }  
  17. return fac;  
  18. });  
  19. //})();  
I am also sharing the error screenshot.
 
Please guide- where am I going wrong.
Please help as it is very urgent.
THank you all in advance.

Answers (6)