In Angular.js - How to check the value of the selected option on a Dropdown?
I have a dropdown menu, and a plus button next to it.
When the button is pressed a function triggers. How do I get "selected" into a var?
({{selected}} works in html, but I want this value in JS)
> <select ng-options="key as key for (key, prop) in
> vm.schema.properties" ng-model="selected"">
> </select> //the dropdown
<p id="plusbutton"> //the add button
<div class="btn btn-info btn-sm" ng-model="selected" ng-click="vm.addMappingField()">
<span class="glyphicon glyphicon-plus"></span>
</div>
</p>
Javascript/Angular:
function addMappingField() {
var item = {{selected}}; //Here should be the value of the dropdown
vm.mappingFields.push({
destination: "item",
});
};