我在 Angular2 Dart Angular for Dart Cheat Sheet (v2.0.0-beta.2)中看到支持 Elvis 运算符。
我正在尝试在组件视图中使用它,但似乎在这里不允许。
给定
.html
<div
<label
for = "first">First<span class = "require">*</span></label>
<input
type = "text"
[(ngModel)] = "name?.first"
id = "first">
。镖
...
Name name = new Name();
...
运行应用程序会出现以下错误:
错误跟踪
Transform TemplateCompiler on
epimss_ng2_reg|lib/components/name_component.ng_meta.json threw error: Template parse errors:
Parser Error: The '?.' operator cannot be used in the assignment at column 13 in [name?.first=$event] in NameComponent@39:12 ("
<input
type = "text"
[ERROR ->][(ngModel)] = "name?.first"
#firstCtrl = "ngForm"
[ngFormControl] = "nameForm"): NameComponent@39:12
什么情况下可以在组件视图中使用操作符?
干杯