在角度控制器中打开Outlook [英] Open an Outlook within angular controller

查看:558
本文介绍了在角度控制器中打开Outlook的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这有效:

HTML

<a href="mailto:?subject={{vm.property.address.streetNumber}}, {{vm.property.address.streetName}} {{vm.cityName}} {{vm.stateName}}%20IPL%20#%20{{vm.property.id}}&body={{comment.note}}">@L("CsEmail")</a>

这不起作用:

<a ng-href="{{vm.email}}" ng-click="vm.composeEmail(comment)">@L("CsEmail")</a>

js

vm.composeEmail = function (data) {
vm.email = "mailto:?subject={{vm.property.address.streetNumber}}, {{vm.property.address.streetName}} {{vm.cityName}} {{vm.stateName}}%20IPL%20#%20{{vm.property.id}}&body={{data.note}}";

    // I need to save this here

                };

问:我需要在发送电子邮件后保存数据,因此我不能使用第一个选项,但是第二个选项不起作用,这意味着它没有打开前景.该怎么做?

Q : I need to save the data after sending the email.Hence I cannot use the first option.But 2nd option is not working.That means it is not opening the outlook. How to do that?

推荐答案

我们从角度控制器中使用它:

We use this from an angular controller:

vm.composeEmail = function (data) {
    var email = "mailto:...";
    //save here
    $window.location.href = email;
};

这样,您可以保存需要保存的所有内容,然后从控制器打开邮件客户端.html看起来像这样:

This way you can save whatever needs to be saved, and then open the mail client from the controller. The html will look something like this:

<a ng-href="" ng-click="vm.composeEmail(comment)">@L("CsEmail")</a>

您还需要按照thegio的建议分解"mailto"字符串.

You also need to break up your 'mailto' string, as thegio suggests.

这篇关于在角度控制器中打开Outlook的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆