为什么这个代码无法在Ionic应用程序中创建Parse对象?

时间:2015-03-29 08:24:08

标签: angularjs parse-platform ionic-framework ionic

我尝试使用Ionic Framework在应用中创建Parse对象,但我无法使其工作。我对编程很新,但我已经能够创建Parse用户,而不是对象。任何人都可以帮我找到解决方案吗?请参阅下面的代码,了解我的控制器。谢谢!

.controller(' AddProspectsController',function($ scope,$ state,$ rootScope){

if (!$rootScope.isLoggedIn) {
    $state.go('welcome');
}

$scope.prospect = {};
$scope.error = {};

// Syntax to create a new subclass of Parse.Object.
//var Prospects = Parse.Object.extend("Prospects");

$scope.addProspect = function() {

    // Create a new instance of that class.
    var Prospects = Parse.Objext.extend("Prospects");
    var prospects = new Prospects();
    prospect.set("name", $scope.prospect.name);
    prospect.set("phone", $scope.prospect.phone);
    prospect.set("email", $scope.prospect.email);
    prospect.set("interest", $scope.prospet.interest);

    prospect.save(null, {
      success: function(prospect) {
        // Execute any logic that should take place after the object is saved.
        $state.go('app.prospects', {clear: true});
        alert('New object created with objectId: ' + prospect.id);
      },
      error: function(prospect, error) {
        // Execute any logic that should take place if the save fails.
        // error is a Parse.Error with an error code and message.
        alert('Failed to create new object, with error code: ' + error.prospect);
      }
    });
}

})

2 个答案:

答案 0 :(得分:1)

此行还有另一个拼写错误:

 var Prospects = Parse.Objext.extend("Prospects");

这不是Objext,而是Object

我希望这会有所帮助。

答案 1 :(得分:0)

有一个拼写错误...你有一个名为prospects的变量带有 “s” ,当你创建对象时,你是使用名为prospect

的变量