ionic 单选框操作

2017-07-20 17:54:00
admin
原创
315
<html ng-app="ionicApp">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
    
    <title></title>
    <link href="https://cdn.bootcss.com/ionic/1.3.2/css/ionic.css" rel="stylesheet">
    <script src="https://cdn.bootcss.com/ionic/1.3.2/js/ionic.bundle.min.js"></script>
    <script type="text/javascript">
    angular.module('ionicApp', ['ionic'])

    .controller('MainCtrl', function($scope) {

      $scope.clientSideList = [
        { text: "Backbone", value: "bb" },
        { text: "Angular", value: "ng" },
        { text: "Ember", value: "em" },
        { text: "Knockout", value: "ko" }
      ];

      $scope.serverSideList = [
        { text: "Go", value: "go" },
        { text: "Python", value: "py" },
        { text: "Ruby", value: "rb" },
        { text: "Java", value: "jv" }
      ];
      
      $scope.data = {
        clientSide: 'ng'
      };
      
      $scope.serverSideChange = function(item) {
        console.log("Selected Serverside, text:", item.text, "value:", item.value);
      };
      
    });
    </script>
    <style type="text/css">
    body {
      cursor: url('http://code.ybao.org/demo/src/finger.png'), auto;
    }
    </style>
  </head>

  <body ng-controller="MainCtrl">
    
    <ion-header-bar class="bar-positive">
      <h1 class="title">当选按钮</h1>
    </ion-header-bar>
             
    <ion-content>
      
      <div class="list">
        
        <div class="item item-divider"> 
          选取的值为: {{ data.clientSide }}
        </div>
        
        <ion-radio ng-repeat="item in clientSideList"
                   ng-value="item.value"
                   ng-model="data.clientSide">
          {{ item.text }}
        </ion-radio>
        
        <div class="item item-divider">
          Serverside, Selected Value: {{ data.serverSide }}
        </div>
        
        <ion-radio ng-repeat="item in serverSideList"
                   ng-value="item.value"
                   ng-model="data.serverSide"
                   ng-change="serverSideChange(item)"
                   name="server-side">
          {{ item.text }}
        </ion-radio>
        
      </div>
      
    </ion-content>
    
  </body>
</html>
文章分类
联系我们
电话: 18902328227
Email: 2689701946@qq.com
QQ: 2689701946
微信: 18902328227
地址: 广州番禺区繁华路
  • 在线客服
  • 关注微信
  • 联系电话
    • 欢迎咨询
    • 欢迎加入QQ群 303257430
  • 公众号:源宝网络
    • 联系电话及微信号 18902328227