我想用单选按钮实现$ionicPopup
。但是,我所尝试的并不像预期的那样工作。我应该有3个选项可供选择,所以如果我选择选项'1'并按'是',我希望控制台日志打印出'1'...到目前为止,我似乎无法连接单选按钮它在控制器中是等效的范围变量。离子弹出式单选按钮
如何反映从离子弹出窗口加载的单选按钮部分的更改?
在控制器:
$ionicPopup.confirm({
templateUrl: 'templates/partials/orderPopup.html',
title: 'XYZ?',
scope: $scope,
buttons: [{
text: 'Yes',
type: 'button-positive',
onTap: function (e) {
console.log($scope.choice);
}
}, {
text: 'No',
type: 'button-default',
onTap: function (e) {
$state.go('shoppingCart');
}
}]
})
,并考虑:
<ion-list ng-controller="shoppingCartCtrl">
<style>
.wrapping-list .item-content, .wrapping-list .item {
overflow: initial;
white-space: initial;
}
</style>
<ion-radio class="wrapping-list" ng-model="choice" ng-value="'1'">Option1</ion-radio>
<ion-radio class="wrapping-list" ng-model="choice" ng-value="'2'">Option2</ion-radio>
<ion-radio class="wrapping-list" ng-model="choice" ng-value="'3'">Option3</ion-radio>
</ion-list>
如果我弹出呼叫之前做出$scope.choice = 2
,那么我就可以看到选项2被选择为默认值,但是,点击任何其他选项,然后单击确定,控制台返回2
预期的行为不清楚 –
我已经编辑它...现在清楚了吗? – Norgul