I am trying to select a dropdown value in angularJs and save it in a service so that i can use it on another view to display the user his selected value and full dropdown.But when i try to log the selected value inside controller.I am getting value of undefined.Please help me how to proceed.
<td>
<select name="systems" class="pulldown1" id="systems" ng-model="system.selectedOption" ng-controller="EurexController" required ng-options="option.name for option in system.availableOptions track by option.id" ng-init="system.selectedOption=system.availableOptions[0]" ng-change="changed()"> </select>
</td>
Controller code:
$scope.system = {
availableOptions: [{
id: 'Domestic 1',
name: 'Domestic 1'
}, {
id: 'Domestic 2',
name: 'Domestic 2'
}, {
id: 'Global',
name: 'Global'
}, {
id: 'Far East',
name: 'Far East'
}],
// selectedOption: {id: 'Domestic 1', name: 'Domestic 1'} //This sets the default value of the select in the ui
};
I also tried using selectedoption mentioned in AngularJS website.But still couldnt do it.
console.log($scope.system.selectedOption);
console.log(systems);