Check out my Plunker demo at the following link: https://plnkr.co/edit/stKf1C5UnCKSbMp1Tyne?p=preview
angular.module('listExample', [])
.controller('ExampleController', ['$scope', function($scope) {
$scope.names = ['morpheus', 'neo', 'trinity'];
}]);
<body ng-app="listExample">
<form name="myForm" ng-controller="ExampleController">
<label>List: <input name="namesInput" ng-model="names" required></label>
<br>
<tt>names = {{names}}</tt><br/>
</form>
</body>
$scope.names
is an array, but in the HTML input field it displays as morpheus,neo,trinity
. How can we display it as ["morpheus","neo","trinity"]
?
If an element is added or removed from the array in the input field, how do we update $scope.names with the new values?