zoukankan      html  css  js  c++  java
  • angularjs中下拉框select option默认值

    1.问题说明:

    option ng-repeat多空白项

    2.解决方案:

    html:

    <ion-view hide-nav-bar="true">
      <ion-content>
        <div class="list card">
          <div>
            <label class="item item-input item-select">
              <div class="input-label">
                <span>安排类型</span>
              </div>
              <select
                ng-change="selectAction()"
                ng-model="selectedType.value"
                ng-init="selectedType.value = ''"
              >
                <option value="">-- 请选择 --</option>
                <option
                  ng-repeat="item in workArrangeTypes"
                  value="{{item.value}}"
                >{{item.name}}</option>
              </select>
            </label>
          </div>
          <div class="item">
            <button style=" 100%;" class="button button-positive" ng-click="submitWork()">提交安排工作</button>
          </div>
         </div>
      </ion-content>
    </ion-view>

    js:

    /************************************** 区域管理 *************************************/
    .controller('RegionalManageCtrl', ['$scope',function($scope) {
      /*** 测试 ***/
      $scope.selectedType = {value: 1}; // 默认值
      $scope.workArrangeTypes = [
        {name: '社区服务', value: 1},
        {name: '教育学习', value: 2},
        {name: '思想汇报', value: 3},
        {name: '电话汇报', value: 4},
        {name: '家庭访问', value: 5}
      ]; // 工作安排类型
    
      // 每次option改变时自动调用该方法
      $scope.selectAction = function() {
        console.log($scope.selectedType.value); // 5
      }
    
      /**
       * 提交工作安排
       */
      $scope.submitWork = function() {
        console.log($scope.selectedType); // {value: 5}
      }
    }])

    3.效果图

  • 相关阅读:
    贝叶斯模型
    java的移位和异或运算
    windows下xgboost安装到python
    bagging and boosting
    SVM处理多分类问题
    GO语言语法入门
    [转自SA]浅谈nginx的工作原理和使用
    多线程编程-- part 9 信号量:Semaphore
    多线程编程-- part 8 CyclicBarrier
    多线程编程-- part 7 CountDownLatch
  • 原文地址:https://www.cnblogs.com/crazycode2/p/9143304.html
Copyright © 2011-2022 走看看