按下提交按钮时如何添加新文本框.这是我尝试过的,我知道有些事情是错的.我仍然是棱角分明的新手.
例:
<!doctype html> <html lang="en"> <head> <Meta charset="UTF-8"> <title>Example - example-ngController-production</title> <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular.min.js"></script> <script> angular.module('controllerAsExample',[]).controller('SettingsController1',function ($scope) { $scope.contacts=[] $scope.addContact = function() { $scope.contact.push({$scope.contact}) } }); }; </script> </head> <body ng-app="controllerAsExample"> <div id="ctrl-as-exmpl" ng-controller="SettingsController1"> <ul> <li ng-repeat="contact in contacts"> <input type="text" ng-model="contact" /> </li> <li><button ng-submit="addContact()">add</button></li> </ul> </div> </body> </html>