角度の新しいjs(1週間前)です。私は、リクエストを送信するために$ httpを使用していたという要件があります。私は、別のページの応答メッセージで受け取ったエラーを表示したいのですが、別のページに値を渡す方法を理解できません。新しいページは、http calls.Belowを作成しているものとは異なります。私はこのコードを書いています。何も動作していないようです。この要件についてどうやって進むのか教えてください。エラーメッセージJSONを別のページテンプレートに渡します。
$http({
method : 'POST',
url : 'http://localhost:8080/abc/users',
data : JSON.stringify(toPass)
}).then(function (data) {
// this callback will be called asynchronously
// when the response is available
console.log(data.data+'a');
$scope.result="The request has been successfully submitted" +data.data.emailId;
$scope.x=data.data.emailId;
console.log('result'+x);
console.log('result');
//$location.path('/Success?{error1}');
window.location="/Success?{x}";
/*if (data.data.error){
$scope.error=data.data.error
}else{
$scope.result=data.data.emailId;
}*/
}, function (error) {
// called asynchronously if an error occurs
// or server returns response with an error status.
console.log("An error encountered"+error);
var error1=error.status;
// $location.path('/Success?{error1}');
});
}
})
のようなサービスを作るあなたの助けWasiqいただきありがとうございます。私はベースとしてあなたのコードを使用し、サービスを作成しました。 – Batman