Just learning angularjs, so practice wrote a shopping cart similar to the full selection/cancellation of the full selection of functions, the main implementation of the functions are:
1, tick Select all checkbox, list data are checked, cancel the same, with Ng-model to achieve two-way binding;
2, select all the checkboxes in the list, the selection will also be checked; (Here I think of the method is to add the checked field for each object, and then tick the trigger Echochange () function, with a CC variable to calculate the current checked is true number, Then you can determine whether the selected number is equal to the length of the array, and the equivalent is all checked, so the Select button is also assigned true; don't know if there's a simpler way? Please tell me the message, thank you! )
3, all check, as long as the cancellation of a full select check status is false;
4, the realization of the shopping cart subtotal and the total amount of calculation, only to calculate the goods that are checked;
There are problems to be perfected:
1, quantity I used the type= "number", set the min=10, but manually entered the value is not limited, so if the manual input will have illegal values;
2, delete the product function I just used the pop () method, remove the last array element, the actual should be deleted for each commodity object;
3, select All/Cancel the full selection should have more rigorous methods, to be perfected;
Attached:
Attached code:
<! DOCTYPE html>
If the above code has a problem or you have better suggestions, you are welcome to contact me, thank you.
angularjs--Shopping Cart Select All/Cancel all Select function