Assuming your products have some kind of id property, this should do the trick:
<select ng-model="promocode.PRODUCT" ng-change="getSomething()" ng-options="product as product.NAME for product in products track by product.id">
track by product.id tells angular to compare array items by their id property, instead of comparing equality between objects.
Here's some more info on tracking / ng-options.
And a working example:
var myApp = angular.module('myApp', []); myApp.controller("controller", function($scope) { $scope.products = [{ id: 1, name: 'FirstProduct' }, { id: 2, name: 'SecondProduct' }]; $scope.promocode = { product: { // Here I am using a placeholder product to illustrate that id: 2 // the select is identifying the correct row by it's `id`. } }; });
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> <div ng-app="myApp" ng-controller="controller"> <select ng-model="promocode.product" ng-change="getSomething()" ng-options="product as product.name for product in products track by product.id"> </select> <br/> {{promocode.product}} </div>
A better option would be to select the correct row, like this:
$scope.promocode = $scope.products[1];
Then you won't have to duplicate any data.
promocode.PRODUCTliterally the same object, or is it an object with the same values? What properties doespromocode.PRODUCThave?products[x]topromocode.PRODUCTsomewhere?==. Objects don 't really play nice with that. (Try:console.log({} == {})). That's why you need atrack byto tell angular to compare theidproperties, instead.