AngularJS, Add Rows -
In the morning,
We are trying to implement this line of addition, it seems Does it seem to repeat our input data? Does anyone know the solution to preview a duplicate field to add a unique ID?
This is our current and example.
$ scope.addRow = function () {var row = {}; $ Scope.productdata.push (line); }; $ Scope.removeRow = function (index) {$ scope.productdata.splice (index, 1); };
< P> $ scope.formData You have no array, but only one object is that all your rows are bound to that object and so they all refer to the same data .
The reason that you add a new line is that your ng-repeat $ scope.productData and you add additional records to it.
A simple example:
In your template
& lt; Div ng-repeat = "Products in the product" & gt; & Lt; Input type = "text" ng-model = "product.title" & gt; & Lt; / Div & gt;
In your controller
$ scope.addProduct = function () {var product = {}; $ Scope.productData.add (product); }
Then you will always only work with the product data array and tie your model for them. In your backend call, you will also use product data instead of your form data.
Hope this will be helpful.
Comments
Post a Comment