I am attempting to use localStorage to remember the user's selection and set the selected option accordingly on their next login.
The select options populate correctly as shown below.
When the index is 1 or above it works correctly, but whenever the first value is selected no value is selected by default on the next reload.
I have illustrated this below:
What am I doing wrong?
HTML
<select name="ipSelect" data-ng-model="selectedOption">
<option ng-repeat="ip in adapters track by $index" data-ng-value="adapters.indexOf(ip)">{{ip}}</option>
</select>
In the controller
ipcRenderer.on('device_ips_loaded', (event, adapters) => {
let storedIndex = localStorage.getItem('defaultIp') || 0
console.log('Adapters: ' + adapters)
console.log('storedIndex: ' + storedIndex)
$scope.adapters = adapters
$scope.$apply(function() {
$scope.selectedOption = adapters[storedIndex]
})
console.log('selectedOption: ' + $scope.selectedOption)
})


