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?
The
ng-submitdirective in angular 1 automatically doespreventDefault()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
submitseems to be broken. I have this in my template:(tried both
(submit)and(^submit))and this method in my component:
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?