I need to add a class to the options produced using ng-options. The options are being listed from a Svc and I'm also needing to insert a class being called from that object. I've seen other threads that show how to do this, but they all referencing a boolean from the object and i just need to call string as the class.
Can anyone lend a hand. I know it's going to be something simple.
<select class="report-user" ng-change="testchange(curTest)" ng-model="curTest" ng-options="value.LinkToken as value.Name for value in tests" options-class="{ 'minor-account' : ALLOWED_FOR_MINOR}" required>
Here is the object called from the Svc:
"Employees": [
{
"ExtensionData": {},
"CanChangeNotices": true,
"CanEditData": true,
"CanRefillScripts": true,
"CanRunReports": true,
"CanViewData": true,
"DateOfBirth": "/Date(1448949600000)/",
"EmployeeClass": "ALLOWED_FOR_MINOR",
"EmployeeMessage": "You have been given access to this employee's information.",
"EmployeeStatus": "Allowed For Minor",
"EmployeeTypeId": 3,
"EmployeeTypeName": "Trainee",
"FirstName": "Sqaweb1",
"HasAccount": false,
"IsAuthorized": false,
"LastName": "Test",
"LinkToken": "XxXxXxXxXxXxXxXx"
},
I'm able to get it to insert names into the option list and associate linkToken, but I just need to make "EmployeeClass" value be the actual class="ALLOWED_FOR_MINOR" (or other values returned from the service) that is actually rendered on the element attribute.
Here's where the controller provides the items for the ng-options.
$scope.tests = [];
$scope.tests = $scope.user.Employees.map(function(item){
return {
'Name':item.FirstName,
'LinkToken':item.LinkToken
}});
$scope.tests.splice(0, 0, {
'Name': $scope.user.FirstName,
'LinkToken': $scope.user.LinkToken
});
$scope.curTest = $scope.tests[0].LinkToken;