首页 > 解决方案 > 在字符串Angular中使用for循环索引

问题描述

我需要它在制作表单的同时遍历不同的对象,我认为处理提交的方式是使用它:

<form (ngSubmit)="submitForm{{u}}()">

问题是我无法弄清楚如何让索引(u)进入字符串而不引发错误。

Parser Error: Got interpolation ({{}}) where expression was expected

我知道

(ngSubmit)={{u}}

可以,但我还需要函数名。

谢谢

标签: angulartypescript

解决方案


正如错误所说,你不需要{{}},它应该是

<form (ngSubmit)="submitForm(u)">

推荐阅读