I have a select dropdown which shows a list of names (using ng-repeat). If there are no names, I want to show a button 'Add Names' and on click on the button I want to perform some function.
I am using a normal select tag and using ng-repeat to show the list of names.
<select ng-model='selectedName' ng-change="onChange()">
<option ng-repeat='name in names'>{{name}}</option>
<option ng-if='!names.length'>
<button ng-click="addName()">Add Name</button>
</option>
In controller:
$scope.names = ['a','b','c','d'];
I expected that on click of the button it will call the addName() function but it is calling onChange() which is on select tag.