Angularjs 发送电子邮件后清除电子邮件
我正在想办法清除列表中的电子邮件。我已经设法创建了一个功能,我可以删除电子邮件一个接一个。但我似乎找不到一种方法,在发送后单击“发送邀请”按钮,如何清除所有这些内容 我正在使用angular.js进行项目,下面是正在进行的代码示例Angularjs 发送电子邮件后清除电子邮件,angularjs,email,Angularjs,Email,我正在想办法清除列表中的电子邮件。我已经设法创建了一个功能,我可以删除电子邮件一个接一个。但我似乎找不到一种方法,在发送后单击“发送邀请”按钮,如何清除所有这些内容 我正在使用angular.js进行项目,下面是正在进行的代码示例 <div class="content referral-sender-page"> <div class="wrapper"> <div class="main" ng-controller="ReferralDispatc
<div class="content referral-sender-page">
<div class="wrapper">
<div class="main" ng-controller="ReferralDispatchController">
<h1 class="h large">Send Invites</h1>
<!-- TODO: Explanatory text -->
<div>
<section class="grid__item bp-md-one-third">
<h5 class="h medium gray">To</h5>
<span ng-repeat="e in emails" class="h small email-list">
<span remove-on-click ng-click="removeEmail(e)" class="email-item">{{ e }} <small class="close">X</small></span>
</span>
<div class="col-2">
<input class="input" type="email"
ng-model="email"
placeholder="Email">
<a ng-click="addEmail()" class="button pads primary" >+</a>
</div>
</section>
<section class="grid__item bp-md-two-thirds">
<h5 class="h medium gray">Message</h5>
<p>Write a message to send to your homies with your invite</p>
<textarea class="text-input" ng-model="message" rows="5">
This is awesome and you should try it!
</textarea>
</section>
</div>
<div class="space--bottom one-whole">
<a ng-click="sendReferral()" class="button pads primary">Send Email Invite</a>
</div>
</div>
</div>
</div>
请使用
var refer = {
emails: angular.copy($scope.emails),
message: angular.copy($scope.message)
};
请查看
它将进行深度复制。因此,当我们更改$scope.emails和$scope.message中的值时,复制的值不会更改
同时清除发送成功
功能中的$Scope.email值请使用
var refer = {
emails: angular.copy($scope.emails),
message: angular.copy($scope.message)
};
$scope.email = []; used to clear the array.
var sendSuccess = function() {
$scope.$emit('notify', { message: 'An invitation has been sent!',
duration: 4000 });
$scope.email = [];
};
请查看
它将进行深度复制。因此,当我们更改$scope.emails和$scope.message中的值时,复制的值不会更改
同时清除
sendsucture
函数中的$Scope.email值请添加服务ReferralService和用户服务请添加服务ReferralService和用户服务
$scope.email = []; used to clear the array.
var sendSuccess = function() {
$scope.$emit('notify', { message: 'An invitation has been sent!',
duration: 4000 });
$scope.email = [];
};