使用 Angular2 输入 onchange [英] Input onchange with Angular2
本文介绍了使用 Angular2 输入 onchange的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试使用 dart 检测变化.示例 html:
<input id="photoUpload" type="file" name="photo" (onchange)="update()" multiple>
飞镖:
@Component(选择器:照片上传对话框",templateUrl:photo_upload_dialog.html")类 PhotoUploadDialog {更新()异步{打印('改变!');}}
但控制台中什么也没有.
解决方案
onChange
是默认的事件处理程序名称,而不是事件名称.
改用
(change)="update()"
I try to detect on change with dart. Example html:
<div>
<input id="photoUpload" type="file" name="photo" (onchange)="update()" multiple>
</div>
Dart:
@Component(
selector: "photo-upload-dialog", templateUrl: "photo_upload_dialog.html")
class PhotoUploadDialog {
update() async {
print('Changed!');
}
}
But nothing in a console.
解决方案
onChange
is the default event handler name, not the event name.
Use instead
(change)="update()"
这篇关于使用 Angular2 输入 onchange的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文