Angular 如何循环模板中的数组?
我正在一个项目中使用 我有一个数字数组:Angular 如何循环模板中的数组?,angular,angular-schematics,Angular,Angular Schematics,我正在一个项目中使用 我有一个数字数组:constnumbers=[1,2,3,4,5] 我想在HTML模板中打印出来。我以以下方式传递数组: export function schematics(_options: Schema): Rule { return (tree: Tree, _context: SchematicContext) => { const numbers = [1, 2, 3, 4, 5]; const sourceTemplate = ur
constnumbers=[1,2,3,4,5]
我想在HTML模板中打印出来。我以以下方式传递数组:
export function schematics(_options: Schema): Rule {
return (tree: Tree, _context: SchematicContext) => {
const numbers = [1, 2, 3, 4, 5];
const sourceTemplate = url('./files');
const sourceParametrizedTemplate = apply(sourceTemplate, [
template({
..._options,
...strings,
numbers
})
]);
return mergeWith(sourceParametrizedTemplate)(tree, _context);
};
}
我在考虑这样做:
index.html
<h1>Numbers</h1>
<%= for(let n in numbers) { =>
<p><%= n %></p>
<%= } %>
数字
但是我得到了错误SyntaxError:Unexpected token for
有人知道实现这一目标的正确方法吗?我在文档中找不到它
谢谢大家! 我终于找到了!我不得不使用
我终于找到了它!我不得不使用看起来像经典asp或asp.net模板代码的。这和angular有什么关系?我用的是angular的原理图。我会说得更清楚,谢谢。这看起来像是经典的asp或asp.net模板代码。这和angular有什么关系?我用的是angular的原理图。我会说得更清楚,谢谢。
<h1>Numbers</h1>
<% for(let n in numbers) { =>
<p><%= n %></p>
<% } %>