AngularJS:在按钮上单击以捕获选定的标记值

时间:2015-05-27 11:07:38

标签: angularjs cordova ionic-framework

我在这里有代码HTMl,我试图从select标签中获取值:

<div class="padding">
        <div class="item item-divider calm-bg" style="color:#ffffff">
        Select Team to Go
        </div>
        <div class="list" >
            <label class="item item-input item-select ">
                <div class="input-label">
                    Select Team
                </div>
                <select ng-model="teamName" ng-options="f.id as f.name for f in devices">
                    <option value="" disabled> Select your team </option>
                </select>
            </label>
        </div>
    </div>

    <div class="clearfix"></div>
<div class="padding">
<div class="item item-divider calm-bg" style="color:#ffffff">
Select Form to Go
</div>
<div class="list">
     <label class="item item-input item-select">
         <div class="input-label">Select Team</div>

                <div ng-if="(!teamName)">
                    <select>
                        <option value="" disabled> Select your form</option>
                    </select>
                </div>
                <div ng-if="(teamName)">
                    <select ng-model="FormModel" ng-options="f.id as f.formname for f in forms | filter:{teamid:teamName}">
                        <option value="" disabled> Select your form </option>
                </div>
            </label>
        </div>
    </div>

    <div class="clearfix"></div>
    <div class="padding">
    <button ng-click="showToFillForm(FormModel)" class="button button-calm pull-right">Go!</button>
    </div>

我正在尝试使用showToFillForm(Formid)捕获表单ID但是它没有捕获如何捕获选择标记值?

1 个答案:

答案 0 :(得分:1)

试试:

<select class="custom-select" ng-model="teamName" data-ng-options="f.id as f.name for f in devices" ng-change="updateTeamObject($index, teamName);">
         <option value="">Select Team</option>
    </select>

 <select class="custom-select" ng-show="teamName" ng-model="deviceForms" data-ng-options="o.id as o.formname for o in forms | filter:{teamid:teamName}">
          <option value="">Your team data</option>
      </select>

并按下按钮

<button ng-click="showToFillForm(deviceForms)" class="button button-calm pull-right">
  Go!
</button>

根据您之前提问的JSON数据

teamName是选择框的先前模型