1
각도 x- 편집 가능을 사용하여 HTML 표를 인라인으로 편집합니다. 문제는 편집 모드로 전환하지 않고 테이블에있는 데이터를 저장하기 위해 사용자 옵션을 제공해야한다는 것입니다. 그렇게하면 onaftersave 메소드에서 스코프 값이 지워집니다.Angularjs xeditable - 편집하지 않고 저장
하지만 편집 모드에서 처음 양식을 놓은 다음 저장을 누르면 모든 것이 올바르게 작동합니다. 그래서 사용자가해야,
<div ng-app="app" ng-controller="Ctrl" style="margin: 50px">
<form editable-form name="tableform" onaftersave="saveTable()">
<table class='table table-bordered'>
<tr style="font-weight: bold">
<td>Name</td>
</tr>
<tr>
<td>
<span editable-text="user.name" e-form="tableform" onaftersave="saveTable()">
{{ user.name || 'empty' }}
</span>
</td>
</tr>
</table>
<div class="btn-edit">
<button type="button" class="btn btn-default" ng-show="!tableform.$visible" ng-click="tableform.$show()">
edit
</button>
<button type="submit" ng-disabled="tableform.$waiting" class="btn btn-primary">save</button>
</div>
<div class="btn-form" ng-show="tableform.$visible">
<button type="button" ng-disabled="tableform.$waiting" ng-click="tableform.$cancel()" class="btn btn-default">cancel</button>
</div>
</form>
<br><br>
<div class="row">
Result is: {{result}}
</div>
</div>
AngularJS와
var app = angular.module("app", ["xeditable"]);
app.run(function(editableOptions) {
editableOptions.theme = 'bs3';
});
app.controller('Ctrl', function($scope, $filter) {
$scope.user = {
name: 'awesome user',
status: 2
};
$scope.saveTable = function(){
$scope.result = $scope.user.name ;
}
$scope.result = '';
});
이를 달성 할 수있는 방법이 있나요 : http://jsfiddle.net/0yvhd84o/
HTML : 여기
는 JSFiddle 문제를 보여주고있다 수정하지 않아도 편집 모드로 전환 할 필요가 없습니다.