Angular js中的JSON服务数据编辑

时间:2015-03-06 10:18:44

标签: javascript json angularjs share ionic-framework

我真正想要的是那个。我想与whatsapp分享我的数据。我设法做到了,但问题是,当我发送数据时,它看起来像这样

"J&J Baby Cl Lemon Frsh 250ML,6, \n","J&J Baby Cl Lemon Frsh 250ML,6, \n","J&J Baby Cl Lemon Frsh 250ML,9, \n","J&J Baby Cl Lemon Frsh 250ML,4, \n","J&J Baby Cl Lemon Frsh 250ML,6, \n","J&J Baby Cl Lemon Frsh 250ML,5, \n"]

我想发送一个像这样的项目列表:

1)J&J Baby Cl Lemon Frsh 250ML [6]
2)J&J Baby Cl Lemon Frsh 250ML [4]
3)J&J Baby Cl Lemon Frsh 250ML [3]
4)J&J Baby Cl Lemon Frsh 250ML [8]

这是我的 HTML

<ion-option-button class="button-calm"
 ng-click="share(item.id)">
         Share
</ion-option-button> 

这是我的 CODE:

    $scope.share = function (listid) {
    $scope.detaillist = [];
    var db = $cordovaSQLite.openDB({ name: "Bd_DB.db" });
    var query = "SELECT * FROM ListDetail WHERE listid= ?";
    $cordovaSQLite.execute(db, query, [listid]).then(function (res) {
        for (var i = 0; i < res.rows.length; i++) {
            $scope.detaillist.push(res.rows.item(i));
        }

        var shareValue = [];

        for (i = 0 ; i < $scope.detaillist.length; i++) {
            shareValue.push($scope.detaillist[i].title + ',' + $scope.detaillist[i].quantity + ',')

        }
        alert(shareValue);

        $cordovaSocialSharing.share(shareValue)

           .then(function (result) {

               // Success!
           }, function (err) {
               alert(JSON.stringify("error" + err));
               // An error occurred. Show a message to the user
           });

     }, function (err) {
         return err;
        alert(JSON.stringify(err));
         console.error(err);
     });





  };

0 个答案:

没有答案