alexpods / angular2-universal-starter

Enjoy Server Side rendering and Web Workers in your Angular2 Application
224 stars 50 forks source link

Route from form submit error in webworker-mode #50

Closed vaseker closed 8 years ago

vaseker commented 8 years ago

Hello. I have an error when submitting form using Enter key and trying to route using form input, but if event happens from input[type="submit"].click(), its okay. In some cases submit event doesn't fire at all. And form submits works fine in not-worker mode.

Error is

TypeError: null is not an object (evaluating 'element.events')

Code sample:

import { Component } from 'angular2/core';
import { NgForm } from 'angular2/common';
import { Router } from 'angular2/router';

@Component({
    selector: 'test-form',
    directives: [NgForm],
    template: `<form (ngSubmit)="onSubmit()">
    <input [(ngModel)]="field" placeholder="Type here smth" />
    <input type="submit" value="go" />
</form>`
})

export class ListComponent {
    field: string = '';

    constructor(private _router: Router) {};

    onSubmit() {
        this._router.navigate( ['SomeRoute', { param: this.field }] );
    }
}
vaseker commented 8 years ago

Got source of issue

EXCEPTION: TypeError: Cannot read property 'events' of null STACKTRACE: TypeError: Cannot read property 'events' of null at WebWorkerRootRenderer._dispatchEvent (http://localhost:8080/worker_app.js:829:21) at Object.next (http://localhost:8080/worker_app.js:818:88)

Which is a part of angular2 package. Moving issue to angular2.