获取Angular ng-option下拉列表的选定文本

Kin*_*mon 4 html javascript angularjs

我的角度代码中有这个下拉列表:

<div class="btn-group" dropdown>
            <select class="selected_location" ng-options="perlocation.id as perlocation.name for perlocation in locations" ng-model="cleaningServiceLocation">
            <option value="">Please Select Location</option>
            </select> 
    <div>
Run Code Online (Sandbox Code Playgroud)

现在在我的控制器中,我可以轻松地将所选值调用为:

$scope.cleaningServiceLocation 
Run Code Online (Sandbox Code Playgroud)

如何获取文本,或者在我的情况下,获取所选位置的名称?

Sam*_*Sam 5

您可以将模型(perlocation)设为对象而不是(perlocation.id) -

<select class="selected_location" ng-options="perlocation as perlocation.name for perlocation in locations" ng-model="cleaningServiceLocation">
Run Code Online (Sandbox Code Playgroud)

并将其作为 -

$scope.cleaningServiceLocation.name
Run Code Online (Sandbox Code Playgroud)