Answer the question
In order to leave comments, you need to log in
AngularJS. Issues with ng-disabled in ng-repead loop. How to select a specific line for editing?
When you click on the pencil (last column), the full name (first column) of this line should be edited.
View:
<body ng-controller="indexController">
<div class="col-sm-6">
<table class="table table-striped">
<thead>
<tr>
<th>ФИО</th>
<th>Год рождения</th>
<th>***</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="item in items">
<td><input type="text" ng-disabled="disabled.$index" ng-init="disabled.$index=true" value="{{item[0]}}"></td>
<td>{{item[1]}}</td>
<td><span class="fas fa-pencil-alt" ng-click="edit($index)"></span></td>
</tr>
</tbody>
</table>
</div>
testApp.controller('indexController', function ($scope, $http){
$http({method: 'POST', url: 'http://public/rest_api/index'}).
then(function success(response) {
$scope.items = response.data;
});
$scope.edit = function (index) {
console.log(index);
$scope.disabled = false;
}
});
$scope.disabled.index = false;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question