2017-08-07 32 views
0

我嘗試構建android並在某些頁面中進行編輯。例如,如果我點擊輸入,它會顯示彈出窗口,並彈出找到輸入文本。輸入一些文本後,點擊確定,輸入文本中的數據將被髮送到服務器。但我不知道如何製作。我可以從Ionic JS Popup發送數據嗎?

這是我HTML

<input class = "button" ng-click = "showPopup()">Add Popup Show /> 

而且這是我JS

$scope.showPrompt = function() { 

     var promptPopup = $ionicPopup.prompt({ 
     title: 'Title', 
     template: 'Template text', 
     inputType: 'text', 
     inputPlaceholder: 'Placeholder' 
     }); 

     promptPopup.then(function(res) { 
     console.log(res); 
     }); 

    }; 

任何人可以幫助我解決我的問題呢?由於

回答

0

我用了ionicPopup秀(希望它可以幫助你):

$scope.updateQ = function() { 
    var alertpop = $ionicPopup.show({ 
     title: 'Quantity', 
     templateUrl: 'popup-template.html', 
     scope: $scope, 
     buttons: [{ 
      text: '<p class="popup-p">Ok</p>', 
      type: 'button-positive', 
      onTap: function(e) { 

       //window.localStorage.setItem("tmpqty",$scope.product.quantity); 
       return $scope.product.quantity; 
      } 
     }, { 
      text: '<p class="popup-p">Cancel</p>', 
      type: 'popup-close', 
      onTap: function(e) { 
       //alert($scope.product.quantity); 
       //return 'cancel button' 
       $state.go('app.productdetail', { product_id: $scope.product_id }, { reload: false }) 
      } 
     }] 
    }); 
    alertpop.then(function(res) { 
     var tmp_qty = res; 
     var pid = $scope.product_id; 
     var url = "" + base_url + "?callback=JSON_CALLBACK&store=1&service=updatevproducts&productid=" + pid + "&qty=" + tmp_qty + ""; 
     $http.jsonp(url) 
      .then(function(response) { 
       var stat = response.data; 
       if (stat.status == "success") { 

        var successPop = $ionicPopup.alert({ 
         template: 'Inventory of Product Id : ' + pid + ' updated successfully !' 
        }); 
        $state.go('app.stocks'); 

       } else { 
        $state.go('app.productdetail', { product_id: $scope.product_id }, { reload: false }); 
       } 
      }); 
    }); 
};