I have a simple form where a user can select a language and press Save. The initial value of the <select>
is the users language on the web page.
I have the following JS code in my controller:
$scope.usersLanguage = loadUsersLanguage(); // e.g. "en"
$scope.allLanguages = loadAllLanguages(); // array of all languages
$scope.interviewLanguage = $scope.usersLanguage; // preselecting the drodown
$scope.logThis() = function() {
console.log($scope.interviewLanguage); // Always prints "en"
}
and the following HTML
<select
ng-model="interviewLanguage"
ng-change="logThis()"
ng-options="language.Id as language.Name for language in allLanguages"
></select>
The ng-change
is just for logging purposes.
My problem is that regardless of what I change the language dropdown to, it always prints the initial value. Never changes. And I've double checked the array allLanguages
, they all have unique ids and names.
Any ideas? Previous similiar StackOverflow-questions were no help.