<div ng-repeat="(key, value) in dataSet | groupBy: 'partner.partnerName'">
<md-select ng-model="selectedUserName" id="myctrl" placeholder="{{ key }}" class="partnerUserList" ng-change="myChange($id)">
<md-option value="{{null}}">{{ key }} </md-option>
<md-option ng-repeat="chatMsg in value" value="{{chatMsg.role.userId}}">{{ chatMsg.role.userId }} </md-option>
</md-select>
</div>
&#13;
我在循环中创建md-select控件,现在当我点击特定的下拉列表时,我需要重置所有下拉列表。我怎样才能实现这一目标?如何获取所选下拉列表的ID?我试过从HTML页面传递这个但没有获得ID?
答案 0 :(得分:1)
传递模型变量并获取控制器中的id
<md-select ng-model="selectedUserName" id="myctrl" placeholder="{{ key }}" class="partnerUserList" ng-change="myChange(selectedUserName)">
<md-option value="{{null}}">{{ key }} </md-option>
<md-option ng-repeat="chatMsg in value" value="{{chatMsg.role.userId}}">{{ chatMsg.role.userId }} </md-option>
</md-select>
<强>控制器:强>
myChange = function(user){
var id = user.role.userid //whatever id ;
}