When the addAgent method is triggered the item is added but the selected option continues and the default option should be selected again.
Controller
$scope.addAgent = function (selectedAgent) {
if (null == selectedAgent) {
alert('Selecione um Agente para adicionar.');
return;
}
$scope.agents.push(selectedAgent);
//mesmo resetando aqui, o último option selecionado continua marcado
$scope.selectedAgent = '';
};
View
<label>Agentes</label>
<select class="form-control"
ng-model="selectedAgent"
ng-options="option as option.name
group by option.type for option in availableAgents track by option.id">
<option value="" ng-selected="selectedAgent ==''">Selecione</option>
</select>
<a ng-click="addAgent(selectedAgent)"
class="btn btn-sm btn-success" title="Adicionar Agente"><i class="fa-plus fa"></i></a>
Example ngOption data format
var availableAgents = [
{id:1, name:"aaaa", "type":"A"},
{id:2, name:"aaaa2", "type":"A"},
{id:3, name:"bbbb", "type":"B"},
];