ユーザーにログインするための投稿要求を書き込もうとしていますが、何も動作しません。なぜ私は見ることができず、どんな援助も喜んでいます!ありがとう!!角度 - ユーザーにログインするためのPOST要求を送信できず、何が間違っているのかわかりません。
マイコントローラ:
'use strict';
app.controller('loginController', function($scope, $state, $http){
$scope.submitLogin=function(email,password)
return $http.post('/login', {email:$scope.email, password:$scope.password })
//私が持っているので、NG-モデル=「メール」 - 私は実際には$のscope.emailに渡す必要はありませんが、メールのみで渡すことができますか?! HTMLの
.then(function(success){
if (sucess){
console.log(success)
$state.go('stories')
}
else {
console.log('error')
}
})
.catch(function(err){
console.log("bad")
})
})
パート:
<div class="form-group">
<label ng-model="email">email</label>
<input type="text" class="form-control" required />
</div>
<div class="form-group">
<label ng-model="password">password</label>
<input type="password" class="form-control" required />
</div>
<button type="submit" class="btn btn-block btn-primary" ng-click="submitLogin()">login</button>
</form>
州:あなたのそれの問題については
'use strict';
app.config(function ($stateProvider) {
$stateProvider.state('login', {
url: '/login',
controller:'loginController',
templateUrl: '/browser/app/login/login.html'
});
});
ng-model = "email"を入力する必要があります。 –
入力にng-modelを入力してもまだ動作しない場合は教えてください。 –
ありがとうございます。それでもうまくいかず、この奇妙なエラーが発生します。エラー:[ng:areq] http://errors.angularjs.org/1.3.20/ng/areq?p0=loginController&p1=not%20aNaNunction%2C%20got% 20undefined – javascript2016