Last active
December 16, 2015 20:49
-
-
Save oliverm2112/5495298 to your computer and use it in GitHub Desktop.
Select list challenge
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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