0

I need to skip the ng-repeat for particular column.

My Code:

<tr ng-repeat="(lunches,price) in lunchTwo">
                    <td>
                      <label class="label_wraptext">{{lunches}}</label>
                    </td>
                    <td class="td_width">
                    </td>
                    <td>
                      <label>{{price}}</label>
                    </td>
                    <td style="padding-left:190px">
                    </td>
                    <td>
                      <select ng-controller="Quantity">
                        <option ng-repeat="key in notSorted(data)" ng-init="value = data[key]">
                          {{key}}
                        </option>
                      </select>
                    </td> 
                  </tr>

I need to avoid binding the 'Select' control for all the rows.

Thanks in Advance, Stephen.L

1 Answer 1

1

Suppose if you want to show the select control only for the first row, you can give a check using the index if it is equals ZERO, then show the select box, else not.

Please find the updated code below, check if it works for you.

<tr ng-repeat="(lunches,price) in lunchTwo">
                    <td>
                      <label class="label_wraptext">{{lunches}}</label>
                    </td>
                    <td class="td_width">
                    </td>
                    <td>
                      <label>{{price}}</label>
                    </td>
                    <td style="padding-left:190px">
                    </td>
                    <td>
                      <select ng-controller="Quantity" ng-show="$index==0">
                        <option ng-repeat="key in notSorted(data)" ng-init="value = data[key]">
                          {{key}}
                        </option>
                      </select>
                    </td> 
                  </tr>
Sign up to request clarification or add additional context in comments.

2 Comments

Good answer, but I would suggest to use ng-if instead of ng-show to completely remove it from the DOM.
yes, you can use ng-if there. But i suggest it as your question how to hide it from the tr. if the answer helps you, then its fine

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.