我正在尝试在其中加载带有ng-repeats的html模板,然后使用该$compile服务编译它并在电子邮件中使用已编译的html.
问题....好问之前让我设置术语...绑定占位符:{{customer.name}}
绑定值:'john doe'
使用$interpolatei获取实际绑定值但不适用于ng-repeats.
示例:var html = $interpolate('<p>{{customer.name}}</p>')($scope)
返回:'<p>john doe</p>'
Ng-repeats不起作用
使用$compile我得到绑定占位符,{{customer.name}}但我需要的是绑定值'john doe'.
示例var html = $compile('<p>{{customer.name}}</p>')($scope:)返回:'<p>{{customer.name}}</p>'
一旦我追加到页面,我就会看到绑定值.但这是用于电子邮件而不是页面加上它具有$compile可以编译的ng-repeats
如何创建动态电子邮件模板,在编译后,它会返回带有绑定值的html而不仅仅是绑定占位符,以便我可以将其作为电子邮件发送?
我正在尝试使用带有Angular 2(Typescript)的D3 v4.我目前正在研究D3 v4.我能够在stackoverflow中跟踪一些类似问题的答案,但没有成功.我导入了大多数D3库及其类型(我使用的是TS 2.0)和我需要的组件文件import * as d3 from 'd3';.这个问题对我来说可能是Angular 2,Typescript和第三方库...到目前为止一团糟.
在我的组件文件中,我有一些代码如下:
let arc = d3.arc()
.outerRadius(chartHeight / 2)
.innerRadius(chartHeight / 4)
.padAngle(0.03)
.cornerRadius(8);
let pieG = chartLayer.selectAll("g")
.data([data])
.enter()
.append("g")
.attr("transform", "translate(" + [chartWidth / 2, chartHeight / 2] + ")");
let block = pieG.selectAll(".arc")
.data(arcs);
let newBlock = block.enter().append("g").classed("arc", true);
newBlock.append("path")
.attr("d", arc)
.attr("id", function (d, i) {
return "arc-" + i
})
.attr("stroke", "gray")
.attr("fill", function (d, i) {
return d3.interpolateCool(Math.random())
});
Run Code Online (Sandbox Code Playgroud)
正如你所看到的,我在第一行定义了arc并在第19行使用了它,但是我收到了一个错误:
[at-loader] src\piechart\piechart.component.ts:19:28 …Run Code Online (Sandbox Code Playgroud) 我一直在用webpack和棱角分明.这可能有一个简单的答案,但我无法弄明白.我已经阅读了这个主题的堆栈溢出中的几乎所有答案都无济于事.
我有一个像这样的html页面(也有其他模板有图像):
<body>
<img ng-src="../images/angular-webpack.png">
<md-button class="md-primary md-raised">
Button
</md-button>
</body>
Run Code Online (Sandbox Code Playgroud)
我也有一个webpack配置:
var webpack = require('webpack');
var CopyWebpackPlugin = require('copy-webpack-plugin');
var path = require('path');
module.exports = {
context: path.resolve(__dirname + '/src'),
entry: ['./js/core/app.module.js'],
output: {
path: './release',
publicPath:'/',
filename: 'app.js'
},
module: {
loaders: [
{
test: /\.html/,
exclude: 'node_modules',
loader: 'raw-loader'
},
{
test: /\.css/,
exclude: 'node_modules',
loader: 'style-loader!css-loader'
},
{
test: /\.(jpe?g|png)$/i,
exclude: 'node_modules',
loader: 'url-loader?limit=8192!img'
}
]
},
plugins: [
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
} …Run Code Online (Sandbox Code Playgroud) angularjs ×2
angular ×1
compilation ×1
d3.js ×1
email ×1
html ×1
javascript ×1
typescript ×1
webpack ×1