How to add dynamic row to a table using angularjs

前端 未结 2 750
孤街浪徒
孤街浪徒 2020-12-05 01:33

Like jQuery, How can I add dynamic rows to a table with form elements in a button click using angularjs and How to differentiate these form elements like array name in norma

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-05 01:51

    You should render the row using ng-repeat, as such:

    1
    {{row.assets}} {{row.selected}} {{row.amount}} {{row.calculation_type}}

    where this is how your controller should look like:

    angular.module('angularSimpleApp').controller('MyCtrl', function ($scope) {
        $scope.newItem = ''; // represents the models in the form
        $scope.rows = [];
        $scope.onSubmit = function(obj) {
            $scope.products.push(obj);
        }
    });
    

提交回复
热议问题