1. 首页
  2. 考试认证
  3. 其它
  4. auth angular clientAngularJS客户端库用于Kidstuff身份验证接口

auth angular clientAngularJS客户端库用于Kidstuff身份验证接口

上传者: 2024-12-10 15:00:00上传 ZIP文件 3.52KB 热度 7次

身份验证客户端用于AngularJS客户端库依赖关系:AngularJS >= MomentJS >= 配置:


app = angular.module('app', ['kidstuff.auth']);

app.config(['authProvider', function(authProvider) {

    authProvider.setEndPoint('http://example.com/auth');

}]);

API参考方法:

  • isLogged():返回布尔值,表示当前用户是否登录

  • currentUser():返回当前用户对象

  • login(email字符串, password字符串, 成功回调(数据), 错误回调(错误))

例子:


app.controller('LoginController', ['$scope', 'auth', function($scope, auth) {

    auth.login('email@example.com', 'password123', function(data) {

        // 成功回调

    }, function(error) {

        // 错误回调

    });

}]);

下载地址
用户评论