私は現在、AngularJSでモーダルダイアログを作成してユーザーをログインしようとしています。したがって、公式ui-bootstrapページのテンプレートを使用して小さな例を作成しました。ユーザーを認証するため、資格証明はRESTサービスに送信されます。簡単にするために、http呼び出しをシミュレートするためにダミーを使用しました。受信したデータが戻ってモーダルダイアログを呼び出したが、何とか私のprmisehandling doesn't仕事と私は次のコードが間違っているというエラーを受け取るコントローラに渡される必要があります。ここではAngularJS Promiseがモーダルでエラーを起こしました
testLoginService.loginUser(user.name, user.pass)
.then(function (sessionId){
user.session = sessionId;
});
はに発生するエラーですコンソール:
Error: testLoginService.loginUser(...) is undefined
[email protected]://localhost:8080/LoginModal/example.js:32:2
Parser.prototype.functionCall/<@http://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.js:10567:15
ngEventDirectives[directiveName]</<.compile/</</<@http://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.js:18627:17
$RootScopeProvider/this.$get</[email protected]://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.js:12412:16
$RootScopeProvider/this.$get</[email protected]://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.js:12510:18
ngEventDirectives[directiveName]</<.compile/</<@http://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.js:18626:15
createEventHandler/eventHandler/<@http://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.js:2780:7
[email protected]://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.js:330:11
createEventHandler/[email protected]://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.js:2779:5
Hereはplunkrのコードです。私のコードで何が原因なのか、それを修正する方法は?最後に、loginServiceから受け取ったデータを処理し、sessionIDやその他のユーザー固有データをユーザーインターフェイスに表示したいと考えています。
あなたはあなたのサービス内の$ http.postに復帰を追加し、コントローラでの成功またはエラーイベントを処理する必要があり、事前