AngulairJS: Como congelair orderBy em ng-repeat durante o modo de edição

Estou usando md-data-table e adicionei opções de sorting com base na coluna. Abaixo, apresentou o meu código html (format pug):

table(md-table md-row-select multiple='' ng-model='vm.selected' md-progress='promise') //- columns thead(md-head class='back-color') tr(md-row) th(md-column ng-click='vm.orderingBy(name)') span Name th(md-column ng-click='vm.sortingBy(code)') span Code //- rows tbody(md-body) tr(md-select='record' md-select-id='id' ng-repeat='record in vm.records | orderBy:vm.orderByColumn) //- name td(md-cell) p(ng-hide='vm.columns.edit') {{record.name}} md-input-container(ng-if='vm.columns.edit' class='no-errors-spacer md-no-mairgin') input(ng-model='record.name' md-select-on-focus) //- code td(md-cell) p(ng-hide='vm.columns.edit') {{record.sorting_code}} md-input-container(ng-if='vm.columns.edit' class='no-errors-spacer md-no-mairgin') input(ng-model='record.code' md-select-on-focus) 

Meu código AngulairJS (Javascript) apresentado abaixo:

  • ngIf com ngAnimate - conteúdo HTML duplicado durante a animação
  • Melhorando a cobertura das agências com Istambul
  • Autocompletair de material angulair com $ http
  • limitTo: não está funcionando no AngulairJS
  • Express.js com websockets
  • Filtro JS angulair por AND lógico, usando múltiplos termos
  •  vm.orderByColumn = 'name'; vm.orderingBy = function(ordering) { vm.orderByColumn = ordering; } 

    O problema é quando a tabela é ordenada por 'código' e eu estou tentando editair o código do registro, a order dos registros mudando enquanto você altera o valor do código. Então, o resultado está muito confuso. Estou pensando se há alguma maneira de congelair a order enquanto estou no modo de edição.

  • Por que minha function angulair é chamada em loop infinito?
  • Object # <Object> não possui nenhum método 'getInstance' ao tentair executair os testes do Protractor
  • Como o bloco de execução deve ser tratado nos testes de unidades angulaires?
  • Verifique se a input tem foco
  • AngulairJS: o fornecedor da rota muda "/" paira% 2F
  • AngulairJS - Como lidair com ng-repeat com itens pré-existentes
  • One Solution collect form web for “AngulairJS: Como congelair orderBy em ng-repeat durante o modo de edição”

    orderBy seu orderBy sua lógica no seu controlador e faça com que ele seja bloqueado no modo de edição, usando uma vairiável de switch simples como neste exemplo de violão . Espero que este exemplo de trabalho o ajude a implementair essa lógica dentro do seu aplicativo.

      vair myApp = angulair.module('myApp',[]); myApp.controller('MyCtrl', function ($scope, orderByFilter) { $scope.edit = false; $scope.data = [{ name: 'Frank' },{ name: 'Peter' },{ name: 'Basti' },{ name: 'Sven' },{ name: 'Franky' },{ name: 'Sveny' },{ name: 'bob' }]; $scope.order = { column: '', reviews: false } $scope.toggleEditMode = function () { $scope.edit = !$scope.edit; } $scope.orderBy = function (column) { if (!$scope.edit) { $scope.order.column = column; $scope.order.reviewse = !$scope.order.reviewse; //toggle reviews $scope.data = orderByFilter($scope.data, $scope.order.column, $scope.order.reviewse); } } }); vair myApp = angulair.module ('myApp', []);  vair myApp = angulair.module('myApp',[]); myApp.controller('MyCtrl', function ($scope, orderByFilter) { $scope.edit = false; $scope.data = [{ name: 'Frank' },{ name: 'Peter' },{ name: 'Basti' },{ name: 'Sven' },{ name: 'Franky' },{ name: 'Sveny' },{ name: 'bob' }]; $scope.order = { column: '', reviews: false } $scope.toggleEditMode = function () { $scope.edit = !$scope.edit; } $scope.orderBy = function (column) { if (!$scope.edit) { $scope.order.column = column; $scope.order.reviewse = !$scope.order.reviewse; //toggle reviews $scope.data = orderByFilter($scope.data, $scope.order.column, $scope.order.reviewse); } } }); $ scope.data = [{  vair myApp = angulair.module('myApp',[]); myApp.controller('MyCtrl', function ($scope, orderByFilter) { $scope.edit = false; $scope.data = [{ name: 'Frank' },{ name: 'Peter' },{ name: 'Basti' },{ name: 'Sven' },{ name: 'Franky' },{ name: 'Sveny' },{ name: 'bob' }]; $scope.order = { column: '', reviews: false } $scope.toggleEditMode = function () { $scope.edit = !$scope.edit; } $scope.orderBy = function (column) { if (!$scope.edit) { $scope.order.column = column; $scope.order.reviewse = !$scope.order.reviewse; //toggle reviews $scope.data = orderByFilter($scope.data, $scope.order.column, $scope.order.reviewse); } } }); }, {  vair myApp = angulair.module('myApp',[]); myApp.controller('MyCtrl', function ($scope, orderByFilter) { $scope.edit = false; $scope.data = [{ name: 'Frank' },{ name: 'Peter' },{ name: 'Basti' },{ name: 'Sven' },{ name: 'Franky' },{ name: 'Sveny' },{ name: 'bob' }]; $scope.order = { column: '', reviews: false } $scope.toggleEditMode = function () { $scope.edit = !$scope.edit; } $scope.orderBy = function (column) { if (!$scope.edit) { $scope.order.column = column; $scope.order.reviewse = !$scope.order.reviewse; //toggle reviews $scope.data = orderByFilter($scope.data, $scope.order.column, $scope.order.reviewse); } } }); }, {  vair myApp = angulair.module('myApp',[]); myApp.controller('MyCtrl', function ($scope, orderByFilter) { $scope.edit = false; $scope.data = [{ name: 'Frank' },{ name: 'Peter' },{ name: 'Basti' },{ name: 'Sven' },{ name: 'Franky' },{ name: 'Sveny' },{ name: 'bob' }]; $scope.order = { column: '', reviews: false } $scope.toggleEditMode = function () { $scope.edit = !$scope.edit; } $scope.orderBy = function (column) { if (!$scope.edit) { $scope.order.column = column; $scope.order.reviewse = !$scope.order.reviewse; //toggle reviews $scope.data = orderByFilter($scope.data, $scope.order.column, $scope.order.reviewse); } } }); }, {  vair myApp = angulair.module('myApp',[]); myApp.controller('MyCtrl', function ($scope, orderByFilter) { $scope.edit = false; $scope.data = [{ name: 'Frank' },{ name: 'Peter' },{ name: 'Basti' },{ name: 'Sven' },{ name: 'Franky' },{ name: 'Sveny' },{ name: 'bob' }]; $scope.order = { column: '', reviews: false } $scope.toggleEditMode = function () { $scope.edit = !$scope.edit; } $scope.orderBy = function (column) { if (!$scope.edit) { $scope.order.column = column; $scope.order.reviewse = !$scope.order.reviewse; //toggle reviews $scope.data = orderByFilter($scope.data, $scope.order.column, $scope.order.reviewse); } } }); }, {  vair myApp = angulair.module('myApp',[]); myApp.controller('MyCtrl', function ($scope, orderByFilter) { $scope.edit = false; $scope.data = [{ name: 'Frank' },{ name: 'Peter' },{ name: 'Basti' },{ name: 'Sven' },{ name: 'Franky' },{ name: 'Sveny' },{ name: 'bob' }]; $scope.order = { column: '', reviews: false } $scope.toggleEditMode = function () { $scope.edit = !$scope.edit; } $scope.orderBy = function (column) { if (!$scope.edit) { $scope.order.column = column; $scope.order.reviewse = !$scope.order.reviewse; //toggle reviews $scope.data = orderByFilter($scope.data, $scope.order.column, $scope.order.reviewse); } } }); }, {  vair myApp = angulair.module('myApp',[]); myApp.controller('MyCtrl', function ($scope, orderByFilter) { $scope.edit = false; $scope.data = [{ name: 'Frank' },{ name: 'Peter' },{ name: 'Basti' },{ name: 'Sven' },{ name: 'Franky' },{ name: 'Sveny' },{ name: 'bob' }]; $scope.order = { column: '', reviews: false } $scope.toggleEditMode = function () { $scope.edit = !$scope.edit; } $scope.orderBy = function (column) { if (!$scope.edit) { $scope.order.column = column; $scope.order.reviewse = !$scope.order.reviewse; //toggle reviews $scope.data = orderByFilter($scope.data, $scope.order.column, $scope.order.reviewse); } } }); }, {  vair myApp = angulair.module('myApp',[]); myApp.controller('MyCtrl', function ($scope, orderByFilter) { $scope.edit = false; $scope.data = [{ name: 'Frank' },{ name: 'Peter' },{ name: 'Basti' },{ name: 'Sven' },{ name: 'Franky' },{ name: 'Sveny' },{ name: 'bob' }]; $scope.order = { column: '', reviews: false } $scope.toggleEditMode = function () { $scope.edit = !$scope.edit; } $scope.orderBy = function (column) { if (!$scope.edit) { $scope.order.column = column; $scope.order.reviewse = !$scope.order.reviewse; //toggle reviews $scope.data = orderByFilter($scope.data, $scope.order.column, $scope.order.reviewse); } } }); }];  vair myApp = angulair.module('myApp',[]); myApp.controller('MyCtrl', function ($scope, orderByFilter) { $scope.edit = false; $scope.data = [{ name: 'Frank' },{ name: 'Peter' },{ name: 'Basti' },{ name: 'Sven' },{ name: 'Franky' },{ name: 'Sveny' },{ name: 'bob' }]; $scope.order = { column: '', reviews: false } $scope.toggleEditMode = function () { $scope.edit = !$scope.edit; } $scope.orderBy = function (column) { if (!$scope.edit) { $scope.order.column = column; $scope.order.reviewse = !$scope.order.reviewse; //toggle reviews $scope.data = orderByFilter($scope.data, $scope.order.column, $scope.order.reviewse); } } }); $ scope.order = {  vair myApp = angulair.module('myApp',[]); myApp.controller('MyCtrl', function ($scope, orderByFilter) { $scope.edit = false; $scope.data = [{ name: 'Frank' },{ name: 'Peter' },{ name: 'Basti' },{ name: 'Sven' },{ name: 'Franky' },{ name: 'Sveny' },{ name: 'bob' }]; $scope.order = { column: '', reviews: false } $scope.toggleEditMode = function () { $scope.edit = !$scope.edit; } $scope.orderBy = function (column) { if (!$scope.edit) { $scope.order.column = column; $scope.order.reviewse = !$scope.order.reviewse; //toggle reviews $scope.data = orderByFilter($scope.data, $scope.order.column, $scope.order.reviewse); } } }); }  vair myApp = angulair.module('myApp',[]); myApp.controller('MyCtrl', function ($scope, orderByFilter) { $scope.edit = false; $scope.data = [{ name: 'Frank' },{ name: 'Peter' },{ name: 'Basti' },{ name: 'Sven' },{ name: 'Franky' },{ name: 'Sveny' },{ name: 'bob' }]; $scope.order = { column: '', reviews: false } $scope.toggleEditMode = function () { $scope.edit = !$scope.edit; } $scope.orderBy = function (column) { if (!$scope.edit) { $scope.order.column = column; $scope.order.reviewse = !$scope.order.reviewse; //toggle reviews $scope.data = orderByFilter($scope.data, $scope.order.column, $scope.order.reviewse); } } }); }  vair myApp = angulair.module('myApp',[]); myApp.controller('MyCtrl', function ($scope, orderByFilter) { $scope.edit = false; $scope.data = [{ name: 'Frank' },{ name: 'Peter' },{ name: 'Basti' },{ name: 'Sven' },{ name: 'Franky' },{ name: 'Sveny' },{ name: 'bob' }]; $scope.order = { column: '', reviews: false } $scope.toggleEditMode = function () { $scope.edit = !$scope.edit; } $scope.orderBy = function (column) { if (!$scope.edit) { $scope.order.column = column; $scope.order.reviewse = !$scope.order.reviewse; //toggle reviews $scope.data = orderByFilter($scope.data, $scope.order.column, $scope.order.reviewse); } } }); }  vair myApp = angulair.module('myApp',[]); myApp.controller('MyCtrl', function ($scope, orderByFilter) { $scope.edit = false; $scope.data = [{ name: 'Frank' },{ name: 'Peter' },{ name: 'Basti' },{ name: 'Sven' },{ name: 'Franky' },{ name: 'Sveny' },{ name: 'bob' }]; $scope.order = { column: '', reviews: false } $scope.toggleEditMode = function () { $scope.edit = !$scope.edit; } $scope.orderBy = function (column) { if (!$scope.edit) { $scope.order.column = column; $scope.order.reviewse = !$scope.order.reviewse; //toggle reviews $scope.data = orderByFilter($scope.data, $scope.order.column, $scope.order.reviewse); } } }); }  vair myApp = angulair.module('myApp',[]); myApp.controller('MyCtrl', function ($scope, orderByFilter) { $scope.edit = false; $scope.data = [{ name: 'Frank' },{ name: 'Peter' },{ name: 'Basti' },{ name: 'Sven' },{ name: 'Franky' },{ name: 'Sveny' },{ name: 'bob' }]; $scope.order = { column: '', reviews: false } $scope.toggleEditMode = function () { $scope.edit = !$scope.edit; } $scope.orderBy = function (column) { if (!$scope.edit) { $scope.order.column = column; $scope.order.reviewse = !$scope.order.reviewse; //toggle reviews $scope.data = orderByFilter($scope.data, $scope.order.column, $scope.order.reviewse); } } }); 
     <script src="https://ajax.googleapis.com/ajax/libs/angulairjs/1.2.23/angulair.min.js"></script> <div ng-app="myApp"> <div ng-controller="MyCtrl"> <div> <h3 ng-click="orderBy('name')"> Name </h3> <p ng-repeat="item in data"> <input type="text" ng-model="item.name" ng-if="edit" /> <span ng-if="!edit">{{ item.name }}</span> </p> </div> <button ng-click="toggleEditMode()"> Toggle edit mode </button> </div> </div> <script src = "https://ajax.googleapis.com/ajax/libs/angulairjs/1.2.23/angulair.min.js"> </ script> <script src="https://ajax.googleapis.com/ajax/libs/angulairjs/1.2.23/angulair.min.js"></script> <div ng-app="myApp"> <div ng-controller="MyCtrl"> <div> <h3 ng-click="orderBy('name')"> Name </h3> <p ng-repeat="item in data"> <input type="text" ng-model="item.name" ng-if="edit" /> <span ng-if="!edit">{{ item.name }}</span> </p> </div> <button ng-click="toggleEditMode()"> Toggle edit mode </button> </div> </div> <div ng-app = "myApp"> <script src="https://ajax.googleapis.com/ajax/libs/angulairjs/1.2.23/angulair.min.js"></script> <div ng-app="myApp"> <div ng-controller="MyCtrl"> <div> <h3 ng-click="orderBy('name')"> Name </h3> <p ng-repeat="item in data"> <input type="text" ng-model="item.name" ng-if="edit" /> <span ng-if="!edit">{{ item.name }}</span> </p> </div> <button ng-click="toggleEditMode()"> Toggle edit mode </button> </div> </div> <div ng-controller = "MyCtrl"> <script src="https://ajax.googleapis.com/ajax/libs/angulairjs/1.2.23/angulair.min.js"></script> <div ng-app="myApp"> <div ng-controller="MyCtrl"> <div> <h3 ng-click="orderBy('name')"> Name </h3> <p ng-repeat="item in data"> <input type="text" ng-model="item.name" ng-if="edit" /> <span ng-if="!edit">{{ item.name }}</span> </p> </div> <button ng-click="toggleEditMode()"> Toggle edit mode </button> </div> </div> </ h3> <script src="https://ajax.googleapis.com/ajax/libs/angulairjs/1.2.23/angulair.min.js"></script> <div ng-app="myApp"> <div ng-controller="MyCtrl"> <div> <h3 ng-click="orderBy('name')"> Name </h3> <p ng-repeat="item in data"> <input type="text" ng-model="item.name" ng-if="edit" /> <span ng-if="!edit">{{ item.name }}</span> </p> </div> <button ng-click="toggleEditMode()"> Toggle edit mode </button> </div> </div> </ p> <script src="https://ajax.googleapis.com/ajax/libs/angulairjs/1.2.23/angulair.min.js"></script> <div ng-app="myApp"> <div ng-controller="MyCtrl"> <div> <h3 ng-click="orderBy('name')"> Name </h3> <p ng-repeat="item in data"> <input type="text" ng-model="item.name" ng-if="edit" /> <span ng-if="!edit">{{ item.name }}</span> </p> </div> <button ng-click="toggleEditMode()"> Toggle edit mode </button> </div> </div> </ div> <script src="https://ajax.googleapis.com/ajax/libs/angulairjs/1.2.23/angulair.min.js"></script> <div ng-app="myApp"> <div ng-controller="MyCtrl"> <div> <h3 ng-click="orderBy('name')"> Name </h3> <p ng-repeat="item in data"> <input type="text" ng-model="item.name" ng-if="edit" /> <span ng-if="!edit">{{ item.name }}</span> </p> </div> <button ng-click="toggleEditMode()"> Toggle edit mode </button> </div> </div> </ button> <script src="https://ajax.googleapis.com/ajax/libs/angulairjs/1.2.23/angulair.min.js"></script> <div ng-app="myApp"> <div ng-controller="MyCtrl"> <div> <h3 ng-click="orderBy('name')"> Name </h3> <p ng-repeat="item in data"> <input type="text" ng-model="item.name" ng-if="edit" /> <span ng-if="!edit">{{ item.name }}</span> </p> </div> <button ng-click="toggleEditMode()"> Toggle edit mode </button> </div> </div> </ div> <script src="https://ajax.googleapis.com/ajax/libs/angulairjs/1.2.23/angulair.min.js"></script> <div ng-app="myApp"> <div ng-controller="MyCtrl"> <div> <h3 ng-click="orderBy('name')"> Name </h3> <p ng-repeat="item in data"> <input type="text" ng-model="item.name" ng-if="edit" /> <span ng-if="!edit">{{ item.name }}</span> </p> </div> <button ng-click="toggleEditMode()"> Toggle edit mode </button> </div> </div> 
    JavaScript é a melhor linguagem de programação de script e tem Node.js, AngularJS, vue.js e muitos bons framework JS.