I'm trying to call a Web API from my website using Angular JS but I'm not getting any data back.
If I run the API separately from my website I get a response back so I know the service is running okay and returning data so it must be the way I'm calling or trying to display the data from my API.
Below is the code from my JS controller on my website.
Any ideas about what the problem is? Thanks
(function () {
var MealsController = function ($scope, $http) {
var meals = function (serviceResp) {
$scope.Meals = serviceResp.data;
};
var errorDetails = function (serviceResp) {
$scope.Error = "Something went wrong ??";
};
$http.get("http://localhost:2153/api/meal")
.then(meals, errorDetails);
$scope.Title = "Meals Details Page";
$scope.Meals = meals;
};
app.controller("MealsController", MealsController); }());
And here is my view HTML code
<!DOCTYPE html>
<html lang="en" ng-app="MealPlannerModule">
<head>
<title>Employee Details</title>
<script src="Scripts/jquery-2.1.3.min.js"></script>
<link href="CSS/amelia.bootstrap.min.css" rel="stylesheet" />
<link href="CSS/Site.css" rel="stylesheet" />
<script src="Scripts/bootstrap.min.js"></script>
<script src="Scripts/angular.min.js"></script>
<script src="Scripts/app.js"></script>
<script src="Controllers/MealsController.js"></script>
</head>
<body ng-controller="MealsController">
<p>Meal Name - {{Meals.mealID}}</p>
</body>
</html>