Quantcast
Channel: Ionic Forum - Latest posts
Viewing all articles
Browse latest Browse all 228595

How to get selected dropdown list value

$
0
0
  • Hi, I am building my first app as a mobile programmer (I have a Windows C# background). I have a view which has a series of rows with three column items: a label, a pre-populated dropdown box and an adjacent textbox. The textbox should only be enabled if 'Other' is selected in the dropdown box. Here's one of the rows:


div class="col col-30">Placement:




ng-disabled="(SelectedItem.Placements !="Other")>undefined>

It doesn't work. The controller has the following code to populate this dropdown box in the view:
$scope.Placements = [{ id: '1', Title: 'Tailgate' },
{ id: '2', Title: 'Line Pump' },
{ id: '3', Title: 'Grout Pump' },
{ id: '4', Title: 'Boom Pump' },
{ id: '5', Title: 'Other' }]

The documentation suggest that I use the GetValue function in the controller to retrieve the selected value. I tried this for the above row:

$scope.GetValue = function (placement) {
var placementId = $scope.SelectedItem.Placements;
var placementName = $.grep($scope.Placements, function (placement) {
return placement.Id == placementId;
})[0].Name;
$window.alert("Selected Value: " + placementId + "\nSelected Text: " + placementName);
}
Last statement was debug -- it didn't execute.
That didn't work either. Do I need to overload this function for each dropdown box? Do I need to wrap each row with a new ng-controller? Is it possible to get the selected value directly without using this function?
Regards,
Bob Fidelman


Viewing all articles
Browse latest Browse all 228595

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>