[英]Issue with angularjs to call http get service
i am trying to do simple http get with angular. 我试图做简单的HTTP获取与角度。 i am using eclipse and jboss. 我正在使用eclipse和jboss。
i already have following rest service /gestionDechets/library/dechet/getRandomDechet
我已经有以下休息服务/gestionDechets/library/dechet/getRandomDechet
which returns: {"idDechets":7,"difficulty":1,"name":"toto","category":"test"}
返回值: {"idDechets":7,"difficulty":1,"name":"toto","category":"test"}
now when i try to call it with angular it does not work. 现在,当我尝试用角度调用它时,它不起作用。
here is my code: 这是我的代码:
get.js get.js
angular.module("mainModule", []).controller("mainController", function ($scope, $http)
{
$scope.getCallJSON = function () {
$http.get('/gestionDechets/library/dechet/getRandomDechet')
.success(function(data) {
$scope.dechet = data;
});
};
})
get.html get.html
<body ng-app="mainModule">
<div ng-controller="mainController">
<button ng-click="getCallJSON()">GET call</button><br />
<textarea class="logTextArea">{{dechet}}</textarea>
</div>
</body>
Nothing happens when i click on GET call button. 当我单击“获取呼叫”按钮时,没有任何反应。
What is wrong in this ? 这有什么问题?
Note: first answer to correct REST path done but issue still persists 注意:正确的REST路径的第一个答案已完成,但问题仍然存在
You are calling the wrong REST service from your code. 您从代码中调用了错误的REST服务。 Compare your question comment to your code 将您的问题注释与代码进行比较
/gestionDechets/library/dechet/getRandomDechet
Versus 与
$http.get('/gestionDechets/library/dechet/retrieveDechet')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.