diff --git a/src/ng/directive/select.js b/src/ng/directive/select.js index 852fcef639aa..b052179eea3b 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`). + *
@@ -338,6 +345,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);