如何使用Javascript将parse.com上的数据放入变量中

时间:2015-04-16 04:13:53

标签: javascript angularjs parse-platform ionic-framework

我正在使用Ionic Framework构建应用程序,所有数据主要存储在parse.com上。我想用户能够离线保存一些数据,所以我正在编写以下函数来实现:

    $scope.doSaveRow = function (_index) {
        console.log(_index);
        ParseRecipeService.get(_index).then(function (_data) {
            $timeout($scope.recipeItem = _data, 0);
        }, function (_error) {
            console.error(_error.message);
        });


        console.log(JSON.stringify($scope.recipeItem));


    };

这是控制台输出:

2     070531   log      [{"description":"Description Goes Here","ingredients":"Ingredients go here","instructions":"Instructions go here","picture":{"__type":"File","name":"tfss-0aa7ed68-8507-47a7-b3b0-666119d6e7f7-sando.jpg","url":"http://files.parsetfss.com/5beeff27-8d26-40bb-aae0-c7429a2f7ee4/tfss-0aa7ed68-8507-47a7-b3b0-666119d6e7f7-sando.jpg"},"resources":"Resources go here","title":"Vegetable Pastry Cups","objectId":"i6jAxjvXEe","createdAt":"2015-03-19T03:01:26.726Z","updatedAt":"2015-03-23T10:56:38.951Z"},{"description":"The fourth description will go here","ingredients":"4th - ingredients go here","instructions":"Instructions for recipe #4 go here","resources":" here","title":"Fourth Recipe","objectId":"XYqNtwqGeY","createdAt":"2015-03-24T07:36:28.763Z","updatedAt":"2015-03-24T07:40:30.008Z"},{"description":"The second desciption will go here","ingredients":"ingredients for recipe #2 go here","instructions":"Instructions for recipe #2 go here","picture":{"__type":"File","name":"tfss-9c8a335a-42a6-43c3-9ef2-fa8234315955-bitcoin.png","url":"http://files.parsetfss.com/5beeff27-8d26-40bb-aae0-c7429a2f7ee4/tfss-9c8a335a-42a6-43c3-9ef2-fa8234315955-bitcoin.png"},"resources":"2nd resources listed here.","title":"Second Recipe","objectId":"qj9HsDcnSi","createdAt":"2015-03-24T07:36:23.001Z","updatedAt":"2015-03-24T07:41:58.448Z"},{"description":"The third description will go here","ingredients":"third - ingredients go ther","instructions":"INstrustions for recipe #3 go here","picture":{"__type":"File","name":"tfss-67139b33-684b-414e-98d9-38d4e657c2fb-isoc-logo.png","url":"http://files.parsetfss.com/5beeff27-8d26-40bb-aae0-c7429a2f7ee4/tfss-67139b33-684b-414e-98d9-38d4e657c2fb-isoc-logo.png"},"resources":"3rd resorces listed here","title":"Third Recipe","objectId":"77uRseaCsr","createdAt":"2015-03-24T07:36:25.034Z","updatedAt":"2015-03-24T07:42:10.558Z"},{"description":"The 5th description will go here","ingredients":"Ingredients go here","instructions":"Instuctions for recipe #5 go here","picture":{"__type":"File","name":"tfss-269ab33c-9de0-4895-b9f0-377ade0a6e43-feeling-station.jpg","url":"http://files.parsetfss.com/5beeff27-8d26-40bb-aae0-c7429a2f7ee4/tfss-269ab33c-9de0-4895-b9f0-377ade0a6e43-feeling-station.jpg"},"resources":"1. Knife, fork, and other resources","title":"5th Recipe","objectId":"XnrNjLi08Y","createdAt":"2015-03-24T07:36:34.094Z","updatedAt":"2015-03-24T07:42:58.709Z"},{"description":"desc goes here","title":"Aurthers new recipe","objectId":"YmnmJDl9fT","createdAt":"2015-03-25T10:13:15.581Z","updatedAt":"2015-03-25T10:14:10.120Z"}]

现在我可以从控制台打印输出看到我的所有数据都在$ scope.recipeItem变量中,但我不知道如何访问存储在描述下的信息。如何将该信息放入变量中?如何离线保存该信息?

0 个答案:

没有答案