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,825
  • 10
  • 37
  • 69
jarus
  • 1,835
  • 11
  • 44
  • 74

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,054
  • 1
  • 9
  • 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
  • 15,447
  • 4
  • 47
  • 66
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
  • 2,925
  • 1
  • 23
  • 19