In my controller, I am trying to extract the second value in an array list that a user selects from a dropdown so that I can perform mathematical operations on it.
$scope.dropdown = [
{name:'Name', value:'123'}]
When a user chooses "Name" from the dropdown, I need to retrieve the value '123'. While I know how to do this on the front-end using:
<p> {{dropdown.value}} </p>
I am struggling to achieve the same in the controller.
I have attempted:
var variable = $scope.dropdown.value;
var variable = $scope.dropdown[0].value;
var variable = $scope.dropdown.value[0];
Unfortunately, none of these methods seem to work.
Here is a snippet of what I am currently working with:
$scope.input1 = "";
var rate = 2;
$scope.dropdown = [
{name:'Name', value:'123'}
];
var activities = (Number($scope.input1) * $scope.dropdownSelection.value * rate) / 2;
console.log(activities);
Essentially, I am trying to perform calculations in the controller based on user inputs and dropdown selections, as well as predefined variables. However, I am unable to retrieve the selected value from the dropdown array.