title: Angular form submission causes page to reload (production only)
body: <p>I have a form that looks like </p>
  
  <pre><code>&lt;form (ngSubmit)="onSubmit(myForm)" 
        #myForm="ngForm"&gt;
    &lt;mat-form-field&gt;
      &lt;input matInput placeholder="Field" [(ngModel)]="field" name="field"&gt;
    &lt;/mat-form-field&gt;
    &lt;button mat-raised-button color="primary"&gt;Submit&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>I am importing <code>FormsModule</code> in my module and when the code is built for development everything works as expected. When I build the project for production the page reloads and no console log is provided.</p>
  
  <p>I tried providing <code>$event</code> to the submit handler and explicitly stopping the default behavior (which is something <code>ngSubmit</code> should take care of implicitly as far as I know), but that didn't help.</p>
  
  <p>The package versions are following</p>
  
  <pre><code>+-- @angular/animations@5.1.2
  +-- @angular/cdk@5.0.2
  +-- @angular/cli@1.6.1
  +-- @angular/common@5.1.2
  +-- @angular/compiler@5.1.2
  +-- @angular/compiler-cli@5.1.2
  +-- @angular/core@5.1.2
  +-- @angular/flex-layout@2.0.0-beta.12
  +-- @angular/forms@5.1.2
  +-- @angular/http@5.1.2
  +-- @angular/language-service@5.1.2
  +-- @angular/material@5.0.2
  +-- @angular/platform-browser@5.1.2
  +-- @angular/platform-browser-dynamic@5.1.2
  +-- @angular/router@5.1.2
  +-- @types/jasmine@2.5.54
  +-- @types/jasminewd2@2.0.3
  +-- @types/node@6.0.95
  +-- codelyzer@4.0.2
  +-- core-js@2.5.3
  +-- jasmine-core@2.6.4
  +-- jasmine-spec-reporter@4.1.1
  +-- karma@1.7.1
  +-- karma-chrome-launcher@2.1.1
  +-- karma-cli@1.0.1
  +-- karma-coverage-istanbul-reporter@1.3.1
  +-- karma-jasmine@1.1.1
  +-- karma-jasmine-html-reporter@0.2.2
  +-- protractor@5.1.2
  +-- rxjs@5.5.6
  +-- ts-node@3.2.2
  +-- tslint@5.7.0
  +-- typescript@2.4.2
  `-- zone.js@0.8.18
  </code></pre>
  
  <p>When I checked a project I worked on a little while ago, it uses the very same code and the application doesn't face this issue. Is there perhaps something, that should be done differently in new version of Angular?</p>
  
  <p><strong>Edit:</strong> When I made the changes suggested in comments which were</p>
  
  <ul>
  <li>Change the button type to <code>button</code></li>
  <li>Explicitly call the submit handler from button click</li>
  </ul>
  
  <p>The page still reloads and it's caused by checking form validity.</p>
  
  <pre><code>onSubmit(form: NgForm){
    if (form.form.invalid)
      return;
  }
  </code></pre>
  
  <p>This is not the original cause as removing the validity check without making the proposed changes doesn't stop the page from reloading.</p>
  
  <p><strong>Edit2:</strong> So it indeed seems to be a package version problem. Here is <a href="https://gitlab.com/pikausp/forms-submission" rel="nofollow noreferrer">git project</a> that demonstrates the problem. With the default packages the issue didn't occure and it appeared once I updated the packages.</p>