diff --git a/src/ng/directive/select.js b/src/ng/directive/select.js
index 8bb93c56ceec..7e58ea68966e 100644
--- a/src/ng/directive/select.js
+++ b/src/ng/directive/select.js
@@ -70,6 +70,13 @@ var ngOptionsMinErr = minErr('ngOptions');
* * `trackexpr`: Used when working with an array of objects. The result of this expression will be
* used to identify the objects in the array. The `trackexpr` will most likely refer to the
* `value` variable (e.g. `value.propertyName`).
+ *
@@ -337,6 +344,12 @@ var selectDirective = ['$compile', '$parse', function($compile, $parse) {
// - optionGroupsCache[?][0] is the parent: either the SELECT or OPTGROUP element
optionGroupsCache = [[{element: selectElement, label:''}]];
+ if (track && match[2] && valueName !== match[1]) {
+ throw ngOptionsMinErr('trackSelect',
+ "Do not use 'track by' when your select ('{0}') is different from your value ('{1}')",
+ match[1], valueName);
+ }
+
if (nullOption) {
// compile the element since there might be bindings in it
$compile(nullOption)(scope);
diff --git a/test/ng/directive/selectSpec.js b/test/ng/directive/selectSpec.js
index ec40e277cc57..ba243c78d6fc 100644
--- a/test/ng/directive/selectSpec.js
+++ b/test/ng/directive/selectSpec.js
@@ -850,6 +850,15 @@ describe('select', function() {
expect(element.val()).toEqual('4');
});
+ it('should throw an error when trying to combine track by with a complex select expression', function() {
+ expect(function() {
+ createSelect({
+ 'ng-model': 'selected',
+ 'ng-options': 'item.id as item.name for item in values track by item.id'
+ });
+ }).toThrowMinErr('ngOptions','trackSelect', "Do not use 'track by' when your select ('item.id') is different from your value ('item')");
+ });
+
it('should bind to scope value through experession', function() {
createSelect({