【发布时间】:2014-12-15 11:37:21
【问题描述】:
我有这个表单,它使用了 3 个离子单选按钮。有没有办法根据选择的单选按钮移动到不同的页面。例如:我的单选按钮被命名
1.USO 2.OASO 3.TFTSO
如果我选择 USO,我想移动到另一个页面,如果我选择 OASO,我想移动到另一个不同的页面等等。我只想在单击我在代码中实现的“继续”按钮后移动。
这就是我在 html 中通过单选按钮和继续按钮实现的方式
<label class="labelColor">
<h5><b>Select Standing Order Type</b></h5>
</label>
<div class="list">
<ion-radio ng-repeat="item in clientSideList"
ng-value="item.value"
ng-model="data.clientSide">
{{ item.text }}
</ion-radio>
</div>
<!-- BUTTONS -->
<div class="col"
style="text-align: center">
<button align="left"
class="button button-block button-reset"
style="display:
inline-block;width:100px;text-align:center "
type="reset"
ng-click="submitted = false; reset()"
padding-top="true">
Reset
</button>
<button class="button button-block button-positive"
style="display: inline-block;width:100px "
ng-click="submitted=true; "padding-top="true">
Proceed
</button>
</div>
我的 angularjs
.controller('OrderCtrl', function($scope,$state) {
$scope.clientSideList = [
{ text: "Utility Standing Order", value: "uso" },
{ text: "Own Account Standing Order", value: "oaso" },
{ text: "Third Party Fund Transfer Standing Order", value: "tpftso" }
];
$scope.data = {
clientSide: 'uso'
};
})
我的控制器
.controller('OrderCtrl', function($scope,$state, $http, $ionicPopup) {
$scope.clientSideList = [
{ text: "Utility Standing Order", value: "uso" },
{ text: "Own Account Standing Order", value: "oaso" },
{ text: "Third Party Fund Transfer Standing Order", value: "tpftso" }
];
$scope.data = {
clientSide: 'uso'
};
$scope.move = function () {
var path;
switch($scope.data.clientSide) {
case 'uso': path = '/so/utilitystanding'; break;
case 'oaso': path = '/so/ownstandingorder'; break;
case 'tpftso': path = '/so/thirdstandingorder'; break;
}
$state.go(app.standing);
};
})
.controller('utilityStandingCtrl', function($scope,$state) {
});
【问题讨论】:
-
获取单选按钮的 id 并检查它是否为 checker 。如果选中,则使用
location.href='the specific url page'。 -
你能给我一个例子吗:)
-
为什么不能只使用更改处理程序?
ng-change -
我想要的是当按下我的继续按钮时,我的表单应该根据选择的单选按钮移动到不同的页面。使用 ng-change,我该如何实现?
标签: javascript jquery html angularjs ionic-framework