How to add delete button in the options of a select component

0

Good day.

I have the following component select multiple

<select multiple ng-model="templateSelect" id="sel_templates" material-select watch ng-change="loadWeeklyConfiguration(templateSelect)">
    <option  ng-repeat="x in templates" value="{{x.id}}" data-icon="delete_outline">
        {{x.title}}
    </option>
</select>

How could you achieve the following with this component?

The boats would execute the action of eliminating the corresponding item.

Thank you in advance

    
asked by devjav 10.07.2018 в 21:27
source

1 answer

0

you could add buttons that call a function, passing the id of the item

    <select multiple ng-model="templateSelect" id="sel_templates" material-select watch ng-change="loadWeeklyConfiguration(templateSelect)">
       <option  ng-repeat="x in templates" value="{{x.id}}" data-icon="delete_outline">
         {{x.title}}
         <button (click)="eliminar(x.id)">
            <span class="glyphicon glyphicon-trash"></span>
         </button>
       </option>
    </select>

and in your file.ts you would only place the delete function (id)

    
answered by 12.07.2018 в 18:50