我需要替换模板中的特殊键,然后在编译和插入 DOM 之前以角度手动下载这些键。可能角度应该在内部具有这样的功能,所以我不想使用任何第三方库。
例子:
$http.get('app/components/shapes/box.html', {cache: $templateCache}).then(function (response) {
var template = response.data;
template = template
.replace(/\{\{number\}\}/gm, number)
.replace(/(\r\n|\n|\r)/gm, '');
});
}
我可以轻松地将密钥从 {{$key}} 更改为其他内容,但我认为 Angular 应该具有内部功能来执行此类操作。
例如:
var newTemplate = angular.funcWhichINeed(template, {
varA: value1,
varB: value2
});