-
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:</div> <div class="col col-30"> <select ng-model="SelectedItem.Placements" ng-options="placement as placement.Title for placement in Placements"></select> </div> <input type="text" ng-model="newMix.Placement" style="background-color:#ffd800" ng-disabled="(SelectedItem.Placements !="Other")>
</div> </div>
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