里面我有两个输入框。推送#confirmButton工作正常,它只是提交表单并从两个输入中获取值。但是,如果我输入输入然后按回车键,我会得到以下异常:
core.umd.js:3370 EXCEPTION: Error in ./MdInput class MdInput - inline template:0:1054 caused by: Expression has changed after it was checked. Previous value: 'true'. Current value: 'false'.ErrorHandler.handleError @ core.umd.js:3370next @ core.umd.js:6838schedulerFn @ core.umd.js:6088SafeSubscriber.__tryOrUnsub @ Subscriber.js:223SafeSubscriber.next @ Subscriber.js:172Subscriber._next @ Subscriber.js:125Subscriber.next @ Subscriber.js:89Subject.next @ Subject.js:55EventEmitter.emit @ core.umd.js:6080onError @ core.umd.js:6303onHandleError @ core.umd.js:6179ZoneDelegate.handleError @ zone.js:207Zone.runGuarded @ zone.js:113NgZoneImpl.runInnerGuarded @ core.umd.js:6187NgZone.runGuarded @ core.umd.js:6419outsideHandler @ platform-browser.umd.js:1829ZoneDelegate.invokeTask @ zone.js:236Zone.runTask @ zone.js:136ZoneTask.invoke @ zone.js:304
core.umd.js:3372 ORIGINAL EXCEPTION: Expression has changed after it was checked. Previous value: 'true'. Current value: 'false'.
如果我调用enableProdMode(),我很确定异常会消失,但这不是修复。
模板示例:
<form class="row" (ngSubmit)="_confirm()">
<ng-content></ng-content>
<div class="row col-md-100 button-container">
<button md-button type="button" (click)="_cancel()">{{'translate.button.cancel' | translate}}</button>
<span class="col-fill"></span>
<button md-button color="primary" #confirmButton>{{'translate.button.confirm' | translate}}</button>
</div>
</form>
对此的任何合理修复都会很棒,我更喜欢修复这个父母然后进入所有使用它的孩子。 谢谢!
编辑: 到目前为止,我已经尝试触发onSubmit事件,并覆盖了keydown事件,所有事情都在父母身上 - 还没有想到这一点,而且我的选项已经用完了。