使用 Angular 2 Beta,我似乎无法让 <input type="file">
正常工作。
使用诊断工具,我可以看到其他 type
,如 text
,的双向绑定。
<form>
{{diagnostic}}
<div class="form-group">
<label for="fileupload">Upload</label>
<input type="file" class="form-control" [(ngModel)]="model.fileupload">
</div>
</form>
在我的 TypeScript 文件中,我有以下诊断行:get diagnostic() { return JSON.stringify(this.model); }
可能是因为它不是JSON的问题吗?该值为null
。
我无法真正验证input
的值。即使“选择文件...”旁边的文本更新了,由于某种原因我看不到DOM中的差异。