AngularJS Material Select 选项组中如何自定义显示的文字?
How to customize displayed text in AngularJS Material Select Option Group?
我这里有一个片段
<span class="filter-lbl">Filter by:</span>
<md-input-container>
<md-select md-container-class="filter-contribution-cont" ng-model="selected" ng-change="selectedChanged(); updateSelectedContribution();" multiple>
<md-optgroup>
<md-option ng-value="data.label" ng-click="dropdownClick(data)" ng-selected="data.selected" ng-repeat="data in dataSet | unique: 'label'">{{data.label}}</md-option>
</md-optgroup>
</md-select>
</md-input-container>
例如,我有一个函数用来构建我想要显示的名为 getSelectedContributions()
的文本,如何替换由 AngularJS [= 制作的内置显示文本23=]?
我对 AngularJS 还是很陌生,所以如果可能的话,我需要一个简单的解决方案。谢谢!
找到答案了。我只需要像这样
在 md-select
中添加 md-selected-text="getSelectedContributions()"
<span class="filter-lbl">Filter by:</span>
<md-input-container>
<md-select md-selected-text="getSelectedContributions()" md-container-class="filter-contribution-cont" ng-model="selected" ng-change="selectedChanged(); updateSelectedContribution();" multiple>
<md-optgroup>
<md-option ng-value="data.label" ng-click="dropdownClick(data)" ng-selected="data.selected" ng-repeat="data in dataSet | unique: 'label'">{{data.label}}</md-option>
</md-optgroup>
</md-select>
</md-input-container>
我这里有一个片段
<span class="filter-lbl">Filter by:</span>
<md-input-container>
<md-select md-container-class="filter-contribution-cont" ng-model="selected" ng-change="selectedChanged(); updateSelectedContribution();" multiple>
<md-optgroup>
<md-option ng-value="data.label" ng-click="dropdownClick(data)" ng-selected="data.selected" ng-repeat="data in dataSet | unique: 'label'">{{data.label}}</md-option>
</md-optgroup>
</md-select>
</md-input-container>
例如,我有一个函数用来构建我想要显示的名为 getSelectedContributions()
的文本,如何替换由 AngularJS [= 制作的内置显示文本23=]?
我对 AngularJS 还是很陌生,所以如果可能的话,我需要一个简单的解决方案。谢谢!
找到答案了。我只需要像这样
在md-select
中添加 md-selected-text="getSelectedContributions()"
<span class="filter-lbl">Filter by:</span>
<md-input-container>
<md-select md-selected-text="getSelectedContributions()" md-container-class="filter-contribution-cont" ng-model="selected" ng-change="selectedChanged(); updateSelectedContribution();" multiple>
<md-optgroup>
<md-option ng-value="data.label" ng-click="dropdownClick(data)" ng-selected="data.selected" ng-repeat="data in dataSet | unique: 'label'">{{data.label}}</md-option>
</md-optgroup>
</md-select>
</md-input-container>