the service is working on spring But when i try to call a service in angular , the result object is empty and nothing is returned
service code :
public class CalculatorController {
@CrossOrigin(origins = "http://localhost:8090")
@GetMapping("/calc/{number1}/{number2}")
public Calculator calc(@PathVariable int number1,
@PathVariable int number2){
Calculator c = new Calculator(number1 , number2) ;
return c;
}
}
controller js code :
angular.module("myApp", [])
.controller("myCtrl", function($scope , $http) {
$http.get('http://localhost:8090/calc/5/8').
then(function (response)
{ $scope.result = response.data; }) ;
});
html code :
<!DOCTYPE html>
<html ng-app="myApp">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<head>
<title>Hello AngularJS</title>
<script src="moule.js"></script>
</head>
<body ng-app="myApp" ng-controller="myCtrl">
<div ng-controller="myCtrl">
<p><span class="add">add is {{ result.add }}</span></p>
<span class="sub">sub is {{ result.sub }}</span>
</div>
</body>
</html>
thanks in advance