I'm using ng-style
to mark something like the label of a team in teams list, and i want to make the name of team will be change base on its color which filled in background of cover area of the team's name. The problem that is if the brightness of background color is gonna be dark, the text color will make the team's name gonna be dim and user unable to read. So how can i do that?
- HTML:
<tr ng-repeat="team in teams">
<td>{{ team.id }}</td>
<td><span ng-style="setColor(team.color)" style="color: #888;">{{ team.name }}</span></td>
</tr>
- Controller:
app.controller('teamController', function($scope){
$scope.teams = [
{
id: '1',
name: 'Driver',
color: '#b9774d'
},
{
id: '2',
name: 'Finance',
color: '#FEFFB3'
}
];
$scope.setColor = function (color){
return {background: color};
}
});