-1

Below is the code, I use select but at change event i got undefined value.

<table id="example1" class="table table-bordered table-striped" ng-table="tableParams" show-filter="isFiltersVisible"> 
  <colgroup>
    <col width="5%"/>
    <col width="5%"/>
  </colgroup>                               
  <tr>
    <td>
      <select ng-change="changed()"
        ng-model="regions"
        ng-options="data.name for data in options">
      </select>             
    </td>
    <td colspan='3'>
      <input type='button' name='go' value='Go' class='btn btn-primary' ng-click="performAction()">
    </td>
  </tr>  
</table>   
Martijn Welker
  • 5,575
  • 1
  • 16
  • 26
Gurpinder
  • 634
  • 1
  • 5
  • 18
  • Take a look at [this](http://stackoverflow.com/questions/18294316/is-ng-model-allowed-inside-td-element-of-a-table). Maybe it's relevant to what you're trying to do – Jonathan La'Fey Feb 09 '16 at 07:50
  • Are you sure `data.name` is correct? Remove the `.name` and stick `{{regions}}` in your view and see what you get. Also `regions` will only be one element, the selected element, not multiple (its plural...) – ste2425 Feb 09 '16 at 08:25
  • if i put my code before td it works fine – Gurpinder Feb 09 '16 at 08:49

1 Answers1

0

If i consider your ng-options the result of this would be that ng-model store the name of the region.

Are you sure your regions is undefined or are you trying to check for regions.name ?

Just in case if you want the whole object in your ng-model :

ng-options="data as data.name for data in options"

Furhtermore the name data/options may conflict with the ng-options directive you should use dot notation : Why don't the AngularJS docs use a dot in the model directive?. SO the best would be :

ng-options="data as data.name for data in model.options

With in your javascript :

$scope.model = {options:[your data]};

Now if it's isn't that please show us the whole code of your controller and if your data is defined somewhere else (like aserver request) show us the format.

Community
  • 1
  • 1
Walfrat
  • 5,363
  • 1
  • 16
  • 35
  • if i put my code before td it works fine – Gurpinder just now edit – Gurpinder Feb 09 '16 at 08:50
  • Yes but since you use some directives (ng-table for instance), you may have conflicts with a generic name like **options**. DId you try rename the fields options in the HTML (and the JS controller) or use the dot thing i explained ? – Walfrat Feb 09 '16 at 09:53
  • @Gurpinder and add your javascript controller code please. – Walfrat Feb 09 '16 at 09:54