The reason the
<select>-element isn't initialized with the value loaded from the cookie, is because it attempts to match the object reference of the initialized object, with the references to the contract objects in your
contractList-variable. Since the initialized object comes from a cookie, it object reference doesn't match any of the objects in the
To solve this, you can specify to the
ngOptions-directive, which attribute it should use to match objects to each other. You do this by appending
track by [expr] to the expression.
So to fix your issue, your template should look somewhat like this:
ng-options="contract.ContractYear for contract in contractList
track by contract.ContractYear">
<option value="">All years</option>
If you have some other unique identifier on the
contract-object (an id for instance), you should naturally opt to track by that instead.
Note: I strongly recommend moving the
ngInit logic to your controller.