AngularJs' ng-repeat allows us to easily traverse the array to generate Dom elements, but improper use will also cause performance problems. Let me share with you the drop-down box using the ng-repeat instruction in the project.
1. Problem background
The option in the select drop-down box is assembled into a drop-down box, and the ng-repeat instruction is used to create it
2. Implement source code
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>AngularJS drop-down box (Method 2)</title> <script type="text/javascript" src="../js/angular.min.js" ></script> <script> var app = angular.module("secondApp",[]); app.controller("secondCon",function($scope){ $scope.trees = ["Pine","campont tree","maple","jujus"]; }); </script> </head> <body> <div ng-app="secondApp" ng-controller="secondCon"> <select> <option ng-repeat="tree in trees">{{tree}}</option> </select> </div> </body> </html>3. Problem description
The ng-repeat directive can repeat data
The above is the AngularJS using the ng-repeat instruction to implement the drop-down box. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to everyone in time. Thank you very much for your support to Wulin.com website!