表单提交错误 - Angular 2 Javascript

Form Submit Error - Angular 2 Javascript

任何人都可以检查这张图片 link 并解释为什么在提交表单后会出现此错误。我已使用 (submit) 提交表单并使用 this.router.navigate(['/Todos']); 导航到下一页。这是我的代码,

login.html

<form #simpleForm="ngForm" (submit)="onSubmit(simpleForm, user)" novalidate>

    <div>
        <input type="text" placeholder="Name" [(ngModel)]="user.name" ngControl="name" #name="ngForm" required />
    </div>

    <button type="submit">Login</button>

</form>

login.js

(function (app) {

    app.LoginComponent = ng.core
            .Component({
                selector: 'login',
                templateUrl: 'login.html',
            })
            .Class({
                constructor: [ng.router.Router, function (router) {
                    this.router = router;
                    this.user = {};
                }],
                onSubmit: function (form, user) {
                    this.router.navigate(['/Todos']);
                },
            });

    ng.router.CanActivate(function (next, prev) {
        return true; //return false to cancel navigation
    })(app.LoginComponent);

})(window.app || (window.app = {}));

这是一个已知问题https://github.com/angular/angular/issues/6786

使用setTimeout()解决

onSubmit: function (form, user) {
  setTimeout(()=>{
    this.router.navigate(['/Todos']);
  }, 10);
},