如何在AngularJS应用程序中使用back4app?

时间:2017-08-05 20:16:04

标签: parsing server back4app

我希望将Back4App与angularjs应用程序一起使用,以便进行简单的用户登录。

我可以这样做吗?

1 个答案:

答案 0 :(得分:1)

是的,这可以完成并完成。使用parse.com上的javascript doc http://docs.parseplatform.org/js/guide/

还有一个nodejs工具。 https://www.npmjs.com/package/angular-parse 你熟悉Angularjs吗?

加载angularjs并用HTML解析

在您的控制器中,从您的登录表单传递数据:

$scope.submitFormReg = function(newUser){
    var user = new Parse.User();
    user.set("username", newUser.user);
    user.set("password", newUser.pass);
    user.set("email", newUser.email);

    user.signUp(null, {
      success: function(user) {
        // Hooray! Let them use the app now.
      },
      error: function(user, error) {
        // Show the error message somewhere and let the user try again.
        alert("Error: " + error.code + " " + error.message);

        Parse.User.logOut().then(() => {
        });
      }
    });
};

$scope.submitFormLogin = function(newUser){
    Parse.User.logIn(newUser.user, newUser.pass, {
      success: function(user) {
        // Do stuff after successful login.
    $location.path('/');

  },
  error: function(user, error) {
    // The login failed. Check error to see why.
    alert(newUser + " login failed: " + error);
  }
    });
};