javascript - Getting the selected string in the dropdown list in Angular -


to begin with, absolute beginner in front-end development, please excuse me if question elementary.

the project working on, drop-down list has been defined as:

<div ng-controller="facetcontroller">     <div class="spnlocationdrop-container" ng-hide="isservicelocal">         <select class="spnlocationdrop" ng-model="$parent.locationsearch" ng-options="location location in locations | sortarray ">             <option value="">all cities</option>         </select>    </div> </div> 

the list contains cities, out-of user has select one. value has stored, , sent backend via ajax call.

how selected value? until now, i've been doing using document.getelementbyid().value() function, since above list contains no id, how value?

ng-model have value of option selected.

here's simple working example: plunker

in example, data.singleselect has value need i'm able output view using {{ data.singleselect }} though if wanted access in controller var input = $scope.data.singleselect , pass input variable backend via ajax call.


Comments

Popular posts from this blog

angular - DownloadURL return null in below code -

meteor - inserting data to database gives error "insert failed: Method '/texts/insert' not found" -