我正在尝试基于名为“ IsDefault” DESC的设置对下拉选项进行排序,然后进行命名,但是似乎无法按照我看过的不同示例添加orderBy。
通过运行“选择”查询,通过nHibernate从数据库中提取数据。
通过以下代码从控制器进行获取数据的调用:
html {
background: #ffffff;
background-image: linear-gradient(180deg, rgb(252, 219, 174) 0%, rgb(255, 255, 255) 100%);
-webkit-font-smoothing: antialiased;
}
body {
background: rgba(250, 255, 238, 0.4);
box-shadow: 0 0 2px rgba(36, 36, 36, 0.06);
color: #545454;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 16px;
line-height: 1.5;
margin: 0 auto;
max-width: 800px;
padding: 2em 2em 4em;
}
包含下拉菜单的.cshtml文件具有以下代码
$scope.getPlaylists = function(activityId){
PlaylistModalService.getPlaylistsForActivity(activityId)
.then(function (data) {
if(data){
$scope.playlistDataForActivity = data.Results;
$scope.numPlaylistOwned = data.MaxCount;
} else {
$scope.playlistDataForActivity = [];
$scope.numPlaylistOwned = 0;
}
$scope.isDataAvailable = true;
MaintainFocusinModal("addToPlaylistModalTplModal");
SetFocusToFirstUserControl("addToPlaylistModalTplModal");
CloseModalOnEscClick("addToPlaylistModalTplModal");
});
};
我尝试了以下方法:
<select id="playListOpt" class="form-control"
ng-model="playlistItem.selectedObjectId"
ng-change="resetModal()" ng-required="true">
<option role="option" value="0" selected>
@Resources.L_LMS_ActDetails.CreateNewPlaylist
</option>
<option role="option"
ng-repeat="playlistItem in playlistDataForActivity
| orderBy:playlistItem.IsDefault:reverse track by playlistItem.Id"
value="{{playlistItem.Id}}">
{{playlistItem.Name}}
</option>
</select>
有没有办法让orderBy在ng-repeat中工作?谢谢!