【发布时间】:2018-09-12 12:58:04
【问题描述】:
我正在尝试从我的 ts 文件中的 Ionic 3 模板中设置一个值,但是我同时也将 css 附加到它。我收到此错误
错误
错误:未捕获(承诺中):错误:表单控件没有值访问器,名称为:'image' 错误:没有名称的表单控件的值访问器:'image'
我的代码如下。
HTML
<img name="image" [(ngModel)]="image" id="image" src="https://openclipart.org/image/2400px/svg_to_png/247149/dual-compass-rose.png" alt="">
TS
this.image.style.transform = 'rotate(' + this.magneticHeading + 'deg)';
我不确定为什么这不起作用,但我开始认为 angular 不喜欢我在.style.transform... 的 TS 文件中尝试做的事情
【问题讨论】:
-
是否有理由同时设置ngmodel和src?
-
没有理由,但这会影响什么吗?
标签: javascript typescript ionic-framework angular-ngmodel