1
            <tbody id="table">
            <tr data-ng-repeat="consulting in consultingsVm.consultings">
                <td>
                    <a href="" class="mode mode--edit"
                       data-ng-click="isModeEdit = !isModeEdit"
                       data-ng-if="!isModeEdit"><span
                            class="mode__item">{{consulting.description}}</span><i
                            class="mode__icon icon-mode_edit"></i></a>
                    <div data-ng-if="isModeEdit">
                        <input type="text" class="input input--edit" data-ng-model="consulting.description">
                        <a href="" class="button button--rounded"
                           data-ng-click="consultingsVm.update(consulting)"><i
                                class="icon-check text--green"></i></a>
                        <a href="" class="button button--rounded" data-ng-click="isModeEdit = false"><i
                                class="icon-arrow_forward"></i></a>
                    </div>
                </td>
                <td class="text--right">
                    <a href="" class="button button--delete"
                       data-ng-click="consultingsVm.deleteConsulting(consulting)">Delete</a>
                </td>
            </tr>
            </tbody>

I want to define variable isModeEdit for every consulting in consultingsVm.consultings. How can i do that?

Tolledo
  • 559
  • 6
  • 20

1 Answers1

1

where do you get the consultingsVm.consultings from.

before u send it to front you could just add the values to it.

then use consulting.isModeEdit

Palm
  • 38
  • 4
  • I'm getting consultings from backend using Rest. And as consulting is the Rest resource, i dont want to add additional parameters to it Is there any other way to solve this issue? – Tolledo Jul 07 '16 at 14:54
  • ok. another way to do it is that me make isModeEdit a function and pass for ex isModeEdit($index) to it then u can have an array to manage the diffrent settings. – Palm Jul 07 '16 at 14:58
  • for ex create the array when you have the data for consultings.. for ex var dataHolder = [false,true,false.. your function isModeEdit can then check dataHolder[the_index_] – Palm Jul 07 '16 at 15:00
  • Another way to do it is to have a scope variable $scope.showName = "consult-0" then set the id on each with there index. click will change the scope var and use ng-hide or show if the scope var matches your id. closing it will set the id to something non existing id thus hinding all – Palm Jul 07 '16 at 15:07
  • data-ng-click="consultingsVm.isModeEdit = $index" working great! thx! – Tolledo Jul 08 '16 at 12:47