Primarily AngularJS is used, not Ionic. To initialize the array of items for the select feature, make sure to set item.checked = true; Check line 164 in the javascript source code and lines 78+ in the HTML source on codepen.
<script>
var $scope.countries = [
{id: 1, name: 'United States', checked: true},
{id: 2, name: 'Germany', checked: false}
]
</script>
<ion-toggle
ng-repeat="item in items"
ng-if="multiSelect"
ng-checked="item.checked"
ng-model="item.checked"
class="item item-text-wrap">
If you want to implement single select, include an angular expression to set a css class:
ng-class="{selected : item.checked}"
Therefore, the label would look like this:
<!-- Single select -->
<label
ng-repeat="item in items"
ng-if="!multiSelect"
class="item item-text-wrap"
ng-class="{selected : item.checked}"
ng-click='validateSingle(item)'>
Add a class to your stylesheet to highlight selected countries when the modal opens:
.selected {
background-color: red !important;
}
If you wish to display the selected country as the label for the fancy select, use something similar to this:
$scope.countries_text_single = $scope.countries[0].name;