在ngFor中循环遍历数组:
<div *ngFor="account of accounts">
<button (click)="function1(); account.message='How do I interpolate {{account.something}} here'"
</div>
我收到错误Got interpolation ({{}}) where expression was expected
如果我只是account.something
没有插值,因为它在单引号之间,它将打印为文字How do I interpolate account.something
答案 0 :(得分:3)
只需使用字符串连接,如:
$date = "4/20/2019";
if( validateDateFormats($date, 'm/d/Y')
|| validateDateFormats($date, 'n/d/Y') ){
print "This date is valid.";
}
答案 1 :(得分:0)
你已经在双引号内写了javascript,所以你不需要编写插值语法。
(click)="All javascript code can be written here without interpolation syntax"