Summary: First, there is a requirement, that is, I click Add, will dynamically appear to input the input box. We need to define an object, like this,
{spc:{},spctions:[]}
This means that the SPC corresponds to an object, and the spctions corresponds to a list. To achieve the effect of dynamic insertion, we just need to insert an empty correspondence into the list of Spctions {}, which is simple.
Finally, you need to insert two tables, which is equivalent to a one-to-many relationship. This should be understood. Of course, here we focus on the principle of dynamic insertion and how angular is implemented.
JS Code
// Add Spec options line $scope. addtablerow=function() { $scope. Entity.specificationOptionList.push ({}); }
HTML code
<tbody> <tr ng-repeat= "Pojo in Entity.specificationoptionlist" > <td> <input class= "Form-control" placeholder= "size Options" ng-model= "Pojo.optionname" > </td> <td> < Input class= "Form-control" placeholder= "Sort" ng-model= "pojo.orders" > </td> <td> <button type= "button" class= "btn btn-default" title= "delete" ng-click= "Deletablerow ($index)" ><i class= "FA Fa-trash-o "></i> Delete </button> </td> </tr> </tbody>
Say something you need to be aware of. That's not going to work, because it'll be an error.
Entity.specificationoptionlist is undefined, so we're going to initialize it. It is best to initialize on the click on the New button because ... (I'll see if I try.)
Add this line to the button
Ng-click= "entity={specificationoptionlist:[]}"
If deleted, the principle is to pass an array coordinate and delete it in the array. Gets the coordinates that traverse the list $index gets
OK super simple. Don't know the message have to say two-way binding cool dead if you use jquery to Kill your frame charm
ANGULARJS Implement dynamic Add input box