I am trying style location two in my array of locations to to have a deleted look, red background, white text that is crossed out. If the user selects this option, the selected option when the dropdown is closed should display the same prior red crossed out label.
This is my desired selected look with the dropdown closed.
Two problems with my sample code, first the option that is to look deleted is not showing the text-decoration:line-through styling... although the red background and white text are being applied by the isDeleted CSS class.
Second, when the deleted option is selected the dropdown in a closed state does not reflect any of the option styling, the text is black with a white background whereas what I want is shown above, red background with white crossed out text.
This below image shows the dropdown open with my cursor over the first option hovering in blue with the deleted option shown in red. But the deleted option is not crossed out even though the class is applied, why?
Also tried adding class styling the select element rather than to the option element but that changes all of the options once the deleted style is applied.
$scope.locations = [
{"label":"123 Main St","locno":1,"deleted":false},
{"label":"456 Main St","locno":2,"deleted":true},
{"label":"789 Main St","locno":3,"deleted":false}
];
$scope.oItem = {"itemName":"Strawberry","locno":2};
.isDeleted{
background-color:red;
color:white;
text-decoration: line-through !important;
}
.isNotDeleted{
background-color:white;
color:black;
text-decoration: none;
}
<select ng-model="oItem.locno">
<option disabled value="">select location</option>
<option ng-repeat="opt in locations"
ng-value="{{opt.locno}}" value="{{opt.locno}}"
ng-class="{'isDeleted':opt.deleted, 'isNotDeleted':!opt.deleted}">{{opt.label}} -- {{opt.deleted}}</option>
</select>