This is my HTML file
<head>
<meta charset="UTF-8"/>
<title>CBIR</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="../js/angular.js"></script>
<script src="../js/AngularCotroller.js"></script>
<script src="../js/ApiCallService.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js" type="text/javascript"></script>
</head>
<body>
<div ng-app="App">
<div ng-controller="AppController">
<div class="form-group row">
<button id="btnGetKey" class="btn btn-default" ng-click="btnGetKey()">Get Key</button>
<p> {{message}}</p>
</div>
<br>
</div>
</div>
</div>
</body>
</script>
This is AngularController.js file
var angularmodule = angular.module('App', []);
angularmodule.controller('AppController', function ($scope, $http, ApiCall) {
//Intital message value
$scope.message = "Don't Give up";
$scope.btnGetkey = function () {
var result = ApiCall.GetKeyFromServer().success(function (data) {
var data = $.parseJSON(JSON.parse(data));
$scope.message = data;
$scope.message = "123123123";
});
};
});
This is ApiServiceCall file
angularmodule.service('ApiCall', ['$http', function ($http)
{
var result;
// This is used for calling get methods from web api
this.GetKeyFromServer = function () {
result = $http.get('http://localhost:8090/CBIR/checkReturn').success(function (data, status) {
result = (data);
}).error(function () {
alert("Something went wrong");
});
return result;
};
}]);
When i load the index file Error: [ng:areq] Argument 'AppController' is not a function, got undefined http://errors.angularjs.org/1.2.16/ng/areq?p0=AppController&p1=not%20a%20function%2C%20got%20undefined i get this error. Please help
App.service('ApiCall'...instead. Let me know whether that works. - Slytherin