$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');
}
}
});
我想从我的数据库值绑定数量,所以如何在ionicPopup中绑定离子弹出窗口中的值?任何帮助都要提前感谢
答案 0 :(得分:2)
你可以做到。这是您的控制器的内容:
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');
}
});
};
这是模板:
<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>