Blacky
Blacky

Reputation: 21

How to do a checking/condition after ng-change in a dropdown

I have the following drop-down button

<select class="input-block-level" ng-model="final_select"
                                ng-options="l.id as l.name group by l.group for l in final_selections['objects']">
                        </select>

How can I print a string like "selected A" below the dropdown, once the object A selected? means ng-change triggered and the value A selected then show the message.

Upvotes: 0

Views: 1583

Answers (2)

Blacky
Blacky

Reputation: 21

Thanks Narendra, that was a great answer. Update to your answer ng-change="onChangeSelected(finalSelected)" to ng-change="onChangeSelected(finalSelected)"

Upvotes: 1

Kerisnarendra
Kerisnarendra

Reputation: 913

Maybe something like below:

$scope.onChangeSelected = function(item) {
  $scope.finalSelected = item;
}
<select class="input-block-level" ng-model="final_select"
  ng-options="l.id as l.name group by l.group for l in final_selections['objects']"
  ng-change="onChangeSelected(finalSelected)">
</select>
<div>
  Selected {{finalSelected.name}}
</div>

Upvotes: 1

Related Questions