How to validate table row data with Angular?

后端 未结 4 1675
醉梦人生
醉梦人生 2021-02-09 16:42

I have table with ng-repeat for table rows. I want to make inline editing and validation of data from single row, but it is impossible to use for

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-09 16:55

    1. I don't think you need to hide your inputs in tds, you could just use CSS to make them fill the td, with no border for example.

    2. As @alonisser said, the angular-way is to create a directive to handle that. To solve my similar case, I created a 'super' table directive which provide my table template and handle its behavior. About the template: I wrapped the table into a form ;)

    HTML example:

    directive example:

    angular.module('myApp').directive('superTable', function() {
      return {
        restrict: 'A',
        templateUrl: 'partials/super-table.html',
        link: function($scope, $elem, $attrs) {
    
          $elem.on('blur', function(e) {
            //do something
          });
        }
      }
    });
    

提交回复
热议问题