I'm implementing a simple email feedback feature in angular app. The mail has predefined mail subject and content template. The angular controller need bring up client email client (like invoke "mailto:foo@bar.com") and fulfill predefined subject, content template. Any body know how to implement it?
我正在角应用程序中实现一个简单的电子邮件反馈功能。邮件具有预定义的邮件主题和内容模板。角度控制器需要调出客户端电子邮件客户端(如调用“mailto:foo@bar.com”)并实现预定义的主题,内容模板。任何人都知道如何实施它?
4 个解决方案
#1
18
Inject $window
and use $window.open()
method.
注入$ window并使用$ window.open()方法。
Inside controller define...
内部控制器定义...
$scope.sendMail = function(emailId,subject,message){
$window.open("mailto:"+ emailId + "?subject=" + subject+"&body="+message,"_self");
};
and call it like...
并称之为......
$scope.sendMail("foo@bar.com","Mail Subject","Mail Body Message");
#2
4
use $window.location:
使用$ window.location:
$window.location = "mailto:..."
#3
1
This should open new tab for Google mail or email client, depending on users settings.
这应该为Google邮件或电子邮件客户端打开新标签,具体取决于用户设置。
In Angular JS: Concatenate string in controller like so:
在Angular JS中:在控制器中连接字符串,如下所示:
$scope.mailLink = "mailto:" + $scope.emailId + "?subject=" + $scope.Subject + '&body=' + $scope.bodyText;
html
HTML
<a ng-href="{{mailLink}}" target="_blank">Send</a>
#4
0
location.href
works too!
location.href也有效!
$scope.email = function(item){
location.href= 'mailto:' + $scope.allemails (array) + '?subject=Subject you want';
}
Note: If you have an array in $scope.allemails
, and you will use method .join(', ')
- thunderbringer email client will not recognize this as a collection of emails and it will add a new line of 'To:' to every email from that array.
注意:如果您在$ scope.allemails中有一个数组,并且您将使用方法.join(',') - thunderbringer电子邮件客户端将不会将此识别为电子邮件的集合,它将添加一行新的“收件人:”来自该阵列的每封电子邮件。
#1
18
Inject $window
and use $window.open()
method.
注入$ window并使用$ window.open()方法。
Inside controller define...
内部控制器定义...
$scope.sendMail = function(emailId,subject,message){
$window.open("mailto:"+ emailId + "?subject=" + subject+"&body="+message,"_self");
};
and call it like...
并称之为......
$scope.sendMail("foo@bar.com","Mail Subject","Mail Body Message");
#2
4
use $window.location:
使用$ window.location:
$window.location = "mailto:..."
#3
1
This should open new tab for Google mail or email client, depending on users settings.
这应该为Google邮件或电子邮件客户端打开新标签,具体取决于用户设置。
In Angular JS: Concatenate string in controller like so:
在Angular JS中:在控制器中连接字符串,如下所示:
$scope.mailLink = "mailto:" + $scope.emailId + "?subject=" + $scope.Subject + '&body=' + $scope.bodyText;
html
HTML
<a ng-href="{{mailLink}}" target="_blank">Send</a>
#4
0
location.href
works too!
location.href也有效!
$scope.email = function(item){
location.href= 'mailto:' + $scope.allemails (array) + '?subject=Subject you want';
}
Note: If you have an array in $scope.allemails
, and you will use method .join(', ')
- thunderbringer email client will not recognize this as a collection of emails and it will add a new line of 'To:' to every email from that array.
注意:如果您在$ scope.allemails中有一个数组,并且您将使用方法.join(',') - thunderbringer电子邮件客户端将不会将此识别为电子邮件的集合,它将添加一行新的“收件人:”来自该阵列的每封电子邮件。