I'm struggling to bind the newly added emails to $scope.emails as it does not contain the new email user added. Any suggestions on how to solve this issue?
// On the server side, emails is a List and email is a string
Initially, I tried binding with ng-model="email" but
However, the following code did not work:
$scope.contactInformation.Emails.push(email); --> throws an error about duplicates
<div ng-repeat="email in emails">
<div class="form-group">
<label for="email">Email</label>
<div class="input-group input-group-sm input-group-minimal">
<span class="input-group-addon">
<i class="linecons-mail"></i>
</span>
<input type="text" class="form-control" ng-model="email" />
</div>
<button class="btn btn-primary" ng-show="$last" ng-click="AddEmail()">Add Email</button>
Controller.js
// When retrieved on the server side, modelParams.ContactInformation.Emails is initialized as new List(string)()
$scope.emails = modelParams.ContactInformation.Emails;
$scope.AddEmail = function () {
$scope.contactInformation.Emails.push({ email: null });
};