Javascript 使用angular并尝试通过电子邮件发送div的内容
因此,我有一个带有类名的div,我正试图找出如何将该div的呈现组件作为文本注入电子邮件正文中。我的电子邮件的所有东西都有效,我尝试使用一个类、一个ng模型等。。。这样做。还没什么效果 我在控制器中处理电子邮件的部分:Javascript 使用angular并尝试通过电子邮件发送div的内容,javascript,html,angularjs,email,Javascript,Html,Angularjs,Email,因此,我有一个带有类名的div,我正试图找出如何将该div的呈现组件作为文本注入电子邮件正文中。我的电子邮件的所有东西都有效,我尝试使用一个类、一个ng模型等。。。这样做。还没什么效果 我在控制器中处理电子邮件的部分: $scope.Subject = "Moneyball Problem Phase Worksheet" $scope.bodyText = '{{ problemExp }}'; $scope.mailLink = "mailto:" + $scope.emailId + "
$scope.Subject = "Moneyball Problem Phase Worksheet"
$scope.bodyText = '{{ problemExp }}';
$scope.mailLink = "mailto:" + $scope.emailId + "?subject=" + $scope.Subject + '&body=' + $scope.bodyText;
以及一次渲染的带有类和ng模型的div,何时包括:
<div class="problemExp" style="background-color: #ffffff; padding: 15px; margin-top: 20px; border: 1px solid #ccc;" ng-model="problemExp">
<div>
<p style="font-size: 12px; color: #afabab;">HYPOTHESIS:</p>
<p style="font-size: 14px;" id="hypCriteria">We believe that <span style="color: blue;">{{ criteria || '[criteria]' }}</span> of <span style="color: blue;">{{ (customer != null) ? customer : '[customer]' }}</span> are most frustrated about <span style="color: blue;">{{ (task != null) ? task : '[task]' }}</span> because <span style="color: blue;">{{ problem || '[problem]' }}</span>.</p>
</div>
<div>
<p style="font-size: 12px; color: #afabab; margin-top: 25px;">CUSTOMER SCREENING CRITERIA:</p>
<p style="font-size: 14px;">We are looking for <span style="color: blue;">{{ (customer != null) ? customer : '[customer]' }}</span> who are regularly involved in <span style="color: blue;">{{ (task != null) ? task : '[task]' }}</span>.</p>
</div>
<div>
<p style="font-size: 12px; color: #afabab; margin-top: 25px;">CUSTOMER INTERVIEW QUESTIONS:</p>
<p style="font-size: 14px;">Tell me about the last time when you were <span style="color: blue;">{{ (task != null) ? task : '[task]' }}</span>?</p>
<p style="font-size: 14px;">What are the major challenges with <span style="color: blue;">{{ (task != null) ? task : '[task]' }}</span>?</p>
<p style="font-size: 14px;">On a scale of 0-10, how frustrating are these problems? Why?</p>
<p style="font-size: 14px;">If you could wave a magic wand and be able to do anything about <span style="color: blue;">{{ (task != null) ? task : '[task]' }}</span> in your daily job, what would it be?</p>
</div>
</div>
假设:
我们认为{{(customer!=null){(customer!=null)}客户:{customer]}中的{criteria}对{(task!=null){(task)}任务:{task]}最失望,因为{{(problem){(problem){problem}}
客户筛选标准:
我们正在寻找{{(客户!=null)?客户:'[customer]'}},他们经常参与{(任务!=null)?任务:'[task]}
客户访谈问题:
告诉我您上次在{{(task!=null)}任务:'[task]}时的情况
{{(task!=null)?task:'[task]}的主要挑战是什么
在0-10的范围内,这些问题有多令人沮丧?为什么?
如果你能挥动魔杖,对日常工作中的{{(task!=null)}任务:'[task]}做点什么,那会是什么
同样,我只想要文本,而不是html元素
如何执行此操作?您可以使用jQuery的命令:
这将产生以下输出:
// HYPOTHESIS:
// We believe that {{ criteria || '[criteria]' }} of {{ (customer != null) ? customer : '[customer]' }} are most frustrated about {{ (task != null) ? task : '[task]' }} because {{ problem || '[problem]' }}.
// CUSTOMER SCREENING CRITERIA:
// We are looking for {{ (customer != null) ? customer : '[customer]' }} who are regularly involved in {{ (task != null) ? task : '[task]' }}.
// CUSTOMER INTERVIEW QUESTIONS:
// Tell me about the last time when you were {{ (task != null) ? task : '[task]' }}?
// What are the major challenges with {{ (task != null) ? task : '[task]' }}?
// On a scale of 0-10, how frustrating are these problems? Why?
// If you could wave a magic wand and be able to do anything about {{ (task != null) ? task : '[task]' }} in your daily job, what would it be?
// HYPOTHESIS:
// We believe that {{ criteria || '[criteria]' }} of {{ (customer != null) ? customer : '[customer]' }} are most frustrated about {{ (task != null) ? task : '[task]' }} because {{ problem || '[problem]' }}.
// CUSTOMER SCREENING CRITERIA:
// We are looking for {{ (customer != null) ? customer : '[customer]' }} who are regularly involved in {{ (task != null) ? task : '[task]' }}.
// CUSTOMER INTERVIEW QUESTIONS:
// Tell me about the last time when you were {{ (task != null) ? task : '[task]' }}?
// What are the major challenges with {{ (task != null) ? task : '[task]' }}?
// On a scale of 0-10, how frustrating are these problems? Why?
// If you could wave a magic wand and be able to do anything about {{ (task != null) ? task : '[task]' }} in your daily job, what would it be?
如果您需要更多地控制如何处理和输出html中的文本内容,可以使用jQuery函数获取每个p
节点的内容:
var out = "";
var paragraph = $(".problemExp").contents();
for (var i = 0; i < y.length; i++) {
if (paragraph[i].nodeType != 3) out = out + paragraph[i].textContent + "\n";
}
console.log(out);
您可以使用jQuery的命令:
这将产生以下输出:
// HYPOTHESIS:
// We believe that {{ criteria || '[criteria]' }} of {{ (customer != null) ? customer : '[customer]' }} are most frustrated about {{ (task != null) ? task : '[task]' }} because {{ problem || '[problem]' }}.
// CUSTOMER SCREENING CRITERIA:
// We are looking for {{ (customer != null) ? customer : '[customer]' }} who are regularly involved in {{ (task != null) ? task : '[task]' }}.
// CUSTOMER INTERVIEW QUESTIONS:
// Tell me about the last time when you were {{ (task != null) ? task : '[task]' }}?
// What are the major challenges with {{ (task != null) ? task : '[task]' }}?
// On a scale of 0-10, how frustrating are these problems? Why?
// If you could wave a magic wand and be able to do anything about {{ (task != null) ? task : '[task]' }} in your daily job, what would it be?
// HYPOTHESIS:
// We believe that {{ criteria || '[criteria]' }} of {{ (customer != null) ? customer : '[customer]' }} are most frustrated about {{ (task != null) ? task : '[task]' }} because {{ problem || '[problem]' }}.
// CUSTOMER SCREENING CRITERIA:
// We are looking for {{ (customer != null) ? customer : '[customer]' }} who are regularly involved in {{ (task != null) ? task : '[task]' }}.
// CUSTOMER INTERVIEW QUESTIONS:
// Tell me about the last time when you were {{ (task != null) ? task : '[task]' }}?
// What are the major challenges with {{ (task != null) ? task : '[task]' }}?
// On a scale of 0-10, how frustrating are these problems? Why?
// If you could wave a magic wand and be able to do anything about {{ (task != null) ? task : '[task]' }} in your daily job, what would it be?
如果您需要更多地控制如何处理和输出html中的文本内容,可以使用jQuery函数获取每个p
节点的内容:
var out = "";
var paragraph = $(".problemExp").contents();
for (var i = 0; i < y.length; i++) {
if (paragraph[i].nodeType != 3) out = out + paragraph[i].textContent + "\n";
}
console.log(out);
谢谢你的信息。我想要的不是包含实际的标签,而是这里生成的文本。在你看到{{”“}}的地方,我只是在寻找从其他地方的表格中填写的文本。关于如何实现这一点的想法?Angular应该在该代码运行之前呈现嵌入式表达式
{{criteria}}
,以便打印出呈现的文本。它没有这样做吗?正确-它只是将以下内容放在电子邮件正文中:假设:我们相信{(客户!=null){(客户)}中的{(客户){(客户)}}对{(任务!=null)}任务最沮丧:{(任务)}因为{(问题){problem}{(问题)}{(问题)}}。客户筛选标准:我们正在寻找{{(客户!=null)?客户:'[CUSTOMER]'}},他们经常参与{(任务!=null)?任务:'[task]'}。客户访谈问题:告诉我您上次{{(任务!=null)}的时间?任务:'[任务…….听起来Angular没有渲染表达式。你确定Angular运行正常吗?你在屏幕上看到正确渲染的文本了吗?也许这个jQuery代码在Angular有机会完成编译/渲染之前就已经运行了?这里有一个更深层次的问题,你需要找到。谢谢你提供的信息。我是什么它不包括实际的标记,而是在这里生成的文本。在您看到{{”“}的地方,我只是在寻找从其他地方的表单中填充的文本。如何实现这一点的想法?Angular应该呈现嵌入的表达式{criteria}
在该代码运行之前,它将打印出呈现的文本。它没有这样做吗?正确-它只是将以下内容放在电子邮件正文中:假设:我们相信{{(customer!=null){(customer!=null)}中的{{(criteria){(criteria)}}个客户:'[customer]}}对{(task!=null)}任务最失望:'[task]}因为{{problem | |'[problem]'}。客户筛选标准:我们正在寻找{{(客户!=null)?客户:'[CUSTOMER]},他们经常参与{(任务!=null)?任务:'[task]}。客户访谈问题:告诉我你上次在{(任务!=null)?task:'[任务…….听起来Angular没有渲染表达式。你确定Angular运行正常吗?你在屏幕上看到正确渲染的文本了吗?也许这个jQuery代码在Angular完成编译/渲染之前就已经运行了?这里有一个更深层次的问题,你需要找到。