0
<select id="marketSelect" ng-model="market" name="marketSelect" ng-change="update()" ng-options=" market.Label group by market.FYear for market in markets" class="form-control">  
</select> 

The ID and label is stored in $cookieStore. I tried to set the default by using the code in the controller

$scope.market = $cookie.get('marketID');

But it does not work, I have tried ng-init also.

Shehary
  • 9,926
  • 10
  • 42
  • 71
jarus
  • 1,853
  • 11
  • 44
  • 76

4 Answers4

0

get is returning a string, in your repeat statement i can see you are using object, instead of put-get can you try putObject-getObject ?

ibrahimbayer
  • 262
  • 1
  • 9
0

What returns this line ?

      $cookie.get('marketID')

I think undefined, please check it.

Ashot
  • 1,229
  • 1
  • 12
  • 13
  • I am getting the id for the selected value, but how can i get the "value" – jarus Aug 27 '15 at 14:30
  • "value" as in because this seems to work $scope.market = $scope.markets[2] but i cannot get the "value" of the option selected, i was able to get the id and the label text but how to get the value that is automatically assigned by angularjs – jarus Aug 27 '15 at 14:44
0

You can solve by this way:

in controller:

$scope.markets = [
  {id:1,Label:'dd',FYear:2015},
  {id:2,Label:'pp',FYear:2014},
  {id:3,Label:'ss',FYear:2015},
  {id:4,Label:'kk',FYear:2014}
  ];

$scope.marketId = 1; // assume $cookie.get('marketID') get value = 1

In html:

<select id="marketSelect" ng-model="marketId" name="marketSelect" ng-change="update()"  ng-options="market.id as market.Label group by market.FYear for market in markets"  class="form-control">

PLUNKER Demo Link

Shaishab Roy
  • 16,335
  • 7
  • 50
  • 68
0

Through Function

$scope.resetfunction= function() {
    $scope.countrylist= "";
}

HTML

<select class="selectBox" ng-model="countrylist" ng-options="list for list in filterCountry | orderBy:'toString()'"><option value="">Select</option></select>
Surya R Praveen
  • 3,393
  • 1
  • 24
  • 25