Skip to content

Instantly share code, notes, and snippets.

@oliverm2112
Last active December 16, 2015 20:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oliverm2112/5495298 to your computer and use it in GitHub Desktop.
Save oliverm2112/5495298 to your computer and use it in GitHub Desktop.
Select list challenge
// cell-template.html
<div ng-cell-has-focus ng-dblclick="editCell()">
<div class="ngCellText">{{getRankName(model.crew[row.rowIndex].rankID)}}</div>
</div>
//cell-edit-template.html
<div>
<select
ng-model="model.crew[row.rowIndex].rankID"
ng-options="rank.rankID as rank.rankName for rank in model.ranks"
style="width: 100%"
ng-cell-input
ng-change="onChange(row, col)"
blur="onChange(row, col)"
>
</select>
</div>
// ListCtrl.js
$scope.getRankName = function (rankID) {
var rankName = '';
angular.forEach($scope.model.ranks, function (rank) {
if (rank.rankID === rankID) {
rankName = rank.rankName;
}
});
return rankName;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment