I've come across a strange issue that I am seeing in Chrome Version 39.0.2171.95 (64-bit) on a Mac using Angular version 1.2.20. When the page first loads, if I tab through a form and change the values of a select list, the select list's model value does not update. Here's a plnkr showing the issue:
http://plnkr.co/edit/0DFI7w9mcp76kSA3lmwE?p=preview
Follow these steps to replicate:
- Click in the first text field and type any value.
- Press Tab
- Type the letter "v" so the select changes to "Vermont".
- Type the letter "v" again, so the select changes to "Virginia".
- Press Tab to enter the next text field.
Notice how the output of data.state is still set to "Vermont", even though the select list is set to "Virginia. Why is this happening and is there any way to fix it?
Here is the HTML from the plnkr:
<!DOCTYPE html>
<html ng-app>
<head>
<script data-require="angular.js@1.2.20" data-semver="1.2.20" src="https://code.angularjs.org/1.2.20/angular.js"></script>
<link rel="stylesheet" href="style.css" />
<script src="script.js"></script>
</head>
<body>
<form name="myForm" ng-init="states = ['Alabama', 'Arizona', 'Arkansas', 'California', 'Colorado', 'Connecticut', 'Delaware', 'District of Columbia', 'Florida', 'Georgia', 'Idaho', 'Illinois', 'Indiana', 'Iowa', 'Kansas', 'Kentucky', 'Louisiana', 'Maine', 'Maryland', 'Massachusetts', 'Michigan', 'Minnesota', 'Mississippi', 'Missouri', 'Montana', 'Nebraska', 'Nevada', 'New Hampshire', 'New Jersey', 'New Mexico', 'New York', 'North Carolina', 'North Dakota', 'Ohio', 'Oklahoma', 'Oregon', 'Pennsylvania', 'Rhode Island', 'South Carolina', 'South Dakota', 'Tennessee', 'Texas', 'Utah', 'Vermont', 'Virginia', 'Washington', 'West Virginia', 'Wisconsin', 'Wyoming']">
<input type="text" ng-model="data.text1">
<select ng-model="data.state" ng-options="value for value in states track by value"></select>
<input type="text" ng-model="data.text2">
</form>
<div>data.text1 = {{ data.text1 }}</div>
<div>data.state = {{ data.state }}</div>
<div>data.text2 = {{ data.text2 }}</div>
</body>
</html>