Skip to content

Framework should preventDefault for form submit events #1039

@jelbourn

Description

@jelbourn

The ng-submit directive in angular 1 automatically does preventDefault() for form submit events, since most people haven't wanted this behavior for about a decade. Angular 2 should probably do the same thing.

UPDATE:
Event handling for submit seems to be broken. I have this in my template:

  <form (submit)="submit('form submit')">
    <button md-button>SUBMIT</button>
    <button>Native button</button>
  </form>

(tried both (submit) and (^submit))

and this method in my component:

  submit(msg: string, event: Event) {
    debugger;
    alert('HALT');
    event.preventDefault();
    this.greeting = msg;
  }

Interacting with either button just causes a full form submit and my event handler is never executed. There are no errors thrown.

@rkirov Any ideas?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions