我目前正在尝试在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或其他用户特定数据。
在此先感谢