1

I have this table:

<table class="table table-striped table-bordered table-responsive" ng-show="viewBusinessUnits">
    <thead>
       <tr>
          <th>Business Unit</th>
          <th>Sales</th>
          <th>Percentage Last Year</th>
          <th>WTD Percentage Last Year</th>
       </tr>
    </thead>
    <tbody>
       <tr ng-repeat="row in tableData">
          <td><a ng-click="toggleTable('{{row.name}}')">{{row.name}}</a></td><!---->
          <td>{{row.sales}}</td>
          <td>{{row.perc_ly}}</td>
          <td>{{row.wtd_perc_ly}}</td>
       </tr>
    </tbody>
<table>


My problem here is that toggleTable('{{row.name}}') is never executed.
When I add the href="#" attribute to the <a> tag, only the anchor works.
When I try and give it a unique ng-model, ng-model='{{row.name}}', then all the columns show the strings {{row.sales}} {{row.perc_ly}} {{row.wtd_perc_ly}} as litterals instead of the corresponding values.

If I create a hardcoded link outside of a table, <a href="#" ng-click="toggleTable('view')">something</a>, it works.

I'm using bootstrap and flot charts in the same page. Could this be the reason why I'm getting this problem?

In every other angular page I'm using this it works, but not this one.

2
  • 2
    Try ng-click="toggleTable(row.name)" Commented Nov 20, 2013 at 8:21
  • sweet! just post that as an answer quickly man, thanks! Commented Nov 20, 2013 at 8:23

1 Answer 1

4

ngClick evaluates the given expression upon click. You dont need interpolation here.

Simply drop the curly braces:

ng-click="toggleTable(row.name)"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.