Я хочу использовать мой веб-сервис без php. С помощью Angular как я могу выполнить веб-сервис с параметром ввода формы. Это настройка REST. И я попробовал мой запрос с POSTMANкак я могу передать свои данные в угловой адрес http:
mY WEB PAGE :
----------------------------------------------------------------------------
<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=windows-1252" http-equiv="content-type">
<title>connexion.html</title>
<script type="text/javascript" src="angular.js"></script>
</head>
<form ng-submit ng-controller="valController" data-action="http://localhost:8080/globalAlfWs/cxf/user/login">
<input type="text" name="login" ng-model="login">
<input type="text" name="password" ng-model="password">
<input type="submit" id="submit" value="Submit">
</form>
</html>
// МОЯ CONTROLLER со ссылкой веб-службы:
var app = angular.module("app",[]);
app.controller('valController',function($scope, $http){
$scope.submit = function(){
$http({
method:'POST',
url:"http://localhost:8080/globalAlfWs/cxf/user/login",
data : {
login: $scope.login,
password: $scope.password
},
headers: {
'Content-Type': 'application/json'
}
})
.success(function(response){
$scope.result = response;
console.log(result);
})
.error(function(){
console.log("error");
});
};
});
----------------------------------------------------------------------------
This is my result with POSTMAN :
{
"results": {
"sessionId": "TICKET_9aee7b3f48fc12e558e6f56b1ede1aea0428cf78",
"success": true,
"userName": "login"
}
}
Мой JS скрипку: code
EDIT/
var appel = angular.module("appel",[]);
appel.controller ('ValController', функция ($ сфера, $ HTTP) {
var data = new FormData;
$scope.submit = function(){
data.append("login",$scope.login);
data.append("password",$scope.password);
$http({
method:'POST',
url:"http://localhost:8080/globalAlfWs/cxf/user/login",
data : data,
headers: {
'Content-Type': undefined
}
})
.success(function(response){
$scope.result = response;
console.log($scope.result);
})
.error(function(){
console.log("error");
});
};
});
Он работает !!
вам нужно 'нг-click' позвонить представить. –
Пожалуйста, сделайте скрипку и plunker и дайте более подробную информацию. – user944513