1
votes

I'm using the smart-table without $scope object, it looks fine, but the selection and callbacks works weird (selection happens only half the time) or do not work at all.

Here, I found an example, as you can see, the row selection works fine.

But if we change syntax to use 'controller As' style, then, it does not work

For now, I will modify my code to use the $scope. But, being a beginner in AngularJS, I would be glad if someone told me why this happens and is there any way to fix that, thank you beforehand.

1

1 Answers

1
votes
  1. your ng-options should be like this

    <select ng-model="events" 
        ng-options="event as event.label for event in vm.events"></select>
    

the event as event.label for event in vm.events means you're pointing to event.label as the event model for each event in vm.events

ngOptions

  1. then add data in the controller

here is your updated plunk

Edit 1

  1. to select the entire row you can bind ng-click to the <tr>, and pass it the current row, like so

    <tr ng-click="vm.selectRow(row)" ... >
    
  2. to highlight the row, you can use ng-class like so

    <tr ... ng-class="{"highlight": row.selected===true}">
    

    and handle the selection logic in the controller. there are a lot of ways to implement this.

forked the last plunk