1
私はまだAngularを少し新しくしていますが、私はAPIバックエンド(私はフロントエンドを構築しています)を通じてログイン後のリクエストを送信しようとしています。Angularログインリクエストに-dを追加する
ので、APIのドキュメントでは、このようなものです:
カール "URL" -d'user [メール]は、いくつかの%40email.com &ユーザー[パスワード] =パスワード&ユーザー[password_confirmation] =パスワードを」= - X POST \ -H "同意する:アプリケーション/何か" \ -H "のContent-Type:アプリケーション/ x-www-form-urlencodedで"
これは私のフォームです:
<form ng-submit='submit()' class='login-form'>
<a ng-href='#/signup'><span class='md-text'>Signup</span></a>
<span class='md-text'>|</span>
<a><span class='md-text'>Forgotten password?</span></a>
<input class='login-input' type='text' ng-model='username' placeholder=' Username'>
<input class='login-input' type='password' ng-model='password' placeholder=' Password'>
<button type="submit" class="btn btn-primary btn-login" ng-model='submit'>Login</button>
</form>
そして、これ私の同僚の一員ですntroller:
$scope.submit=function() {
console.log('Submit');
var reqLogin = {
method: 'POST',
url: 'URL',
headers: {
'Accept': 'application/blah,
'Content-Type': 'application/x-www-form-urlencoded'
}
}
$http(reqLogin).success(function(response) {
console.log(response);
});
}
これはばかげた質問かもしれませんが、私は角にヘッダを追加するために知って、私は上記の持っているJSONオブジェクトで行います。
HTTPリクエストに-d部分を追加するにはどうすればよいですか?