when i click on qty than it will be set on ionicPopup
$ionicPopup.show({
template: '<input type="tel" placeholder="Quantity" ng-model="data.wifi" >',
title: 'Enter quantity to change',
scope: $scope,
buttons: [{
text: '<i class="icon ion-close"></i>', type: 'popup-close'},
{
text: '<b>Ok</b>',
type: 'common-btn',
onTap: function (e) {
qty = $scope.data.wifi;
var date = new Date();
var cartData = {
'companyId': compid,
'userId': userid,
'cartDate': date,
'cartStatus': 1,
'productId': val.ProductID,
'quantity': qty,
'cartDetailStatus': 1
};
//alert(JSON.stringify(cartData));
$http.post($rootScope.url + 'UpdateCartQty?margin=' + marginVal + '&roleid=' + roleid, cartData).success(function (data) {
console.log(JSON.stringify(data));
$ionicPopup.alert({
title: 'Message',
template: 'Quantity updated successfully !'
}).then(function () {
$scope.items = data;
//cartid = data.CartID;
});
});
return qty;
}]
}).then(function (qty) {
if (qty) {
console.log('Got quantity ' + qty);
} else {
//alert('please enter value');
}
}
});
I want to bind quantity from my database value so how can not bind the value in ionic popup it's possible in ionicPopup? any help thanks in advance
You can do it. This is the content of your controller:
var compid = 1;
var userid = 1;
var val = {
ProductID: 1
};
$scope.data = {
wifi: "my wifi data"
};
$scope.openModal = function(){
$ionicPopup.show({
template: '<input type="tel" placeholder="Quantity" ng-model="data.wifi" >',
title: 'Enter quantity to change',
scope: $scope,
buttons: [
{
text: '<i class="icon ion-close"></i>',
type: 'popup-close'
},
{
text: '<b>Ok</b>',
type: 'common-btn',
onTap: function (e) {
qty = $scope.data.wifi;
var date = new Date();
var cartData = {
'companyId': compid,
'userId': userid,
'cartDate': date,
'cartStatus': 1,
'productId': val.ProductID,
'quantity': qty,
'cartDetailStatus': 1
};
//alert(JSON.stringify(cartData));
$http.post($rootScope.url + 'UpdateCartQty?margin=' + marginVal + '&roleid=' + roleid, cartData).success(function (data) {
console.log(JSON.stringify(data));
$ionicPopup.alert({
title: 'Message',
template: 'Quantity updated successfully !'
}).then(function () {
$scope.items = data;
//cartid = data.CartID;
});
});
return qty;
}
}
]
}).then(function (qty) {
if (qty) {
console.log('Got quantity ' + qty);
} else {
//alert('please enter value');
}
});
};
This is the template:
<ion-view view-title="My View">
<ion-content class="padding">
<input type="text" ng-model="data.wifi">
<button class="button" ng-click="openModal()">Open</button>
</ion-content>
</ion-view>