Lucian Lucian - 1 year ago 152
AngularJS Question

Angular How to obtain onselect event

I am displaying some data in a smart-table component(using

). The last column is a select element. What i want to do is plug-in to the "
" change event and do something with the data displayed in the row.

Here is my plunker :

What i want to achieve is displayed in the comment

Answer Source

If you want to create a Dropdown list its better to use ng-option then ng-repeat.

<select ng-option=" for x in myItems"> 

Because the ng-repeat directive repeats a block of HTML code for each item in an array, it can be used to create options in a dropdown list, but the ng-options directive was made especially for filling a dropdown list with options, and has at least one important advantage:

Dropdowns made with ng-options allows the selected value to be an object, while dropdowns made from ng-repeat has to be a string.

Add ng-change

<select ng-change="SelectedRow()" ng-option=" for x in myItems"> 

Then in our controller

$scope.SelectedRow = function(){
          //here take action or do whatever you want to. 
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download