Add new text box on click of a button in angular js

前端 未结 2 1438
Happy的楠姐
Happy的楠姐 2021-01-22 20:18

How do I add new text box when submit button is pushed. This is what I have tried and I know there\'s some thing wrong. I am still new to angular js.

Example:

         


        
2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-22 20:20

    You should replace your ng-submit with ng-click that will solve your problem And with that you need to change your object structure to persist a value, like you need to add contact number in contact object like contact.number

    Markup

    Code

    angular.module('controllerAsExample', [])
    .controller('SettingsController1', function($scope) {
      $scope.contacts = []
      $scope.addContact = function() {
        $scope.contacts.push({
        })
      }
    });
    

    Demo Plunkr

提交回复
热议问题