Reputation: 19
Hi i try to get data from my web API with Angular but i get 404 not found the code is
Html code
<!DOCTYPE html>
<html ng-app="myApp">
<head>
<meta charset="utf-8" />
<title>Simple Web Application</title>
<script src="Scripts/angular.js"></script>
<script src="Scripts/script.js"></script>
</head>
<body >
<div ng-controller="MainController">
<table>
<tr>
<td>ID</td>
<td>Name</td>
</tr>
<tr ng-repeat="emp in employees">
<td>{{emp.id}}</td>
<td>{{emp.Ename}}</td>
</tr>
</table>
</div>
</body>
</html>
Angular code:
var url = "http://localhost:65125/api/Empyloee";
var myApp = angular.module("myApp", []);
var MainController = function ($scope, $http) {
var onSucess = function (response) { $scope.employees = response.data};
var onFailure = function (reason) { $scope.error = reason };
var getAllEmployees = function () {
$http.get(url)
.then(onSucess ,onFailure)
};
getAllEmployees();
};
myApp.controller("MainController", MainController);
thanks for the help
Upvotes: 0
Views: 50
Reputation: 668
It seems to be a problem with that endpoint in your API side. Re-test you API endpoint if it's working correctly. You can check response using POSTMAN before integrate with your angular solution.
Upvotes: 2