7
I have the following HTML structure below. However, when clicking on one of the "items" the class (editing) is displayed for both elements. What should I do to make it happen only in the clicked item?
Editing:
Note: the ng-click, is inside the loop ng-repeat="item in items track by $index"
Simulation in Jsfiddle: http://jsfiddle.net/NfPcH/19444/
<h4>Angular-xeditable Text (Bootstrap 3)</h4>
<form ng-app="app" ng-controller="Ctrl" editable-form name="formulario">
  <!-- Texto I -->
  <a href="#" ng-click="formulario.$show()" ng-show="!formulario.$visible" editable-text="user.name">{{ user.name || 'empty' }}</a>
    <div class="buttons">
      <!-- buttons to submit / cancel form -->
      <span ng-show="formulario.$visible">
        <br/>
        <button type="submit" class="btn btn-primary" ng-disabled="formulario.$waiting">
          Save
        </button>
        <button type="button" class="btn btn-default" ng-disabled="formulario.$waiting" ng-click="formulario.$cancel()">
          Cancel
        </button>
      </span>
    </div>
    <br />
    <!-- Texto II -->
    <a href="#" ng-click="formulario.$show()" ng-show="!formulario.$visible" editable-text="user.name">{{ user.name || 'empty' }}</a>
    <div class="buttons">
      <!-- buttons to submit / cancel form -->
      <span ng-show="formulario.$visible">
        <br/>
        <button type="submit" class="btn btn-primary" ng-disabled="formulario.$waiting">
          Save
        </button>
        <button type="button" class="btn btn-default" ng-disabled="formulario.$waiting" ng-click="formulario.$cancel()">
          Cancel
        </button>
      </span>
    </div>
</form>
Javascript:
var app = angular.module("app", ["xeditable"]);
app.run(function(editableOptions) {
  editableOptions.theme = 'bs3';
});
app.controller('Ctrl', function($scope) {
  $scope.user = {
    name: 'awesome user'
  };
});
						
Lucas, from what I saw in your code the idea is to have a list of users and edit each of them, that’s it?
– Pedro Camara Junior
Yes. @Pedrocamarajunior
– lucasbento