angularjs - ng-model is not passing through correct value -


i have select element in users can select orderby filter,

%select{   "ng-change"  => "select()",    "ng-model"   => "selecteditem",    "ng-options" => "option.sortby option in listofoptions"} 

this listofoptions

$scope.listofoptions = [   {sortby: 'release date',  value:'release_date'},   {sortby: 'newly added',   value:'created_at'} ]; 

and select function,

$scope.select = function(){   console.log($scope.selecteditem.value) } 

in view select box shows both release date , newly added options, when select 1 of them error,

typeerror: cannot read property 'value' of undefined

so looks $scope.selecteditem undefined, can't figure out why.

well did plunker , select works expected

plunker

app.js:

  $scope.listofoptions = [{     sortby: 'release date',     value: 'release_date'   }, {     sortby: 'newly added',     value: 'created_at'   }];    $scope.select = function() {     console.log($scope.selecteditem.value)   } 

index.html:

<select ng-change="select()" ng-options="option.sortby option in listofoptions" ng-model="selecteditem"></select> <p>{{selecteditem}}</p> 

can provide angular version ?


Comments

Popular posts from this blog

SVG stroke-linecap doesn't work for circles in Firefox? -

routes - Laravel 4 Wildcard Routing to Different Controllers -

cross browser - XSLT namespace-alias Not Working in Firefox or Chrome -