components icon indicating copy to clipboard operation
components copied to clipboard

BrowserAnimationsModule, as described in Getting Started, causes a routing error

Open mLaird opened this issue 9 years ago • 25 comments

Bug, feature request, or proposal:

Bug

What is the expected behavior?

routing should show 1 page at a time

What is the current behavior?

When BrowserAnimationsModule is added after BrowserModule in the NgModule imports array (as shown in Getting Started, Step 2), then 2 pages merge vertically and can be seen as 1 'tall' page via vertical scrolling. When BrowserAnimationsModule is removed, routing occurs as expected. The same behavior occurs when BrowserAnimationsModule replaces BrowserModule in the imports array.

What are the steps to reproduce?

add BrowserAnimationsModule to app.module.ts per Getting Started instructions for a 2 page routing app. Perform routing. Observe new merged double vertical page.

Providing a Plunker (or similar) is the best way to get the team to see your issue. Plunker template: https://goo.gl/DlHd6U

What is the use-case or motivation for changing an existing behavior?

BrowserAnimationsModule, as suggested in Getting Started should not break routing.

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

Angular 4.3.6 @angular/material -beta.8 Windows 10 Typescript 2.3.4 both FF and Chrome behave the same

Is there anything else we should know?

The Angular Changelog for 4.3.2 and for 5.0.0-beta.0 both have a bug fix saying "export BrowserModule as apart of BrowserAnimationsModule". Possibly some code bug exists in Angular, rather than MD. Nonetheless, Getting Started has a bug in its instructions as currently stated. It doesn't work, as stated.

mLaird avatar Sep 01 '17 18:09 mLaird

yup, getting the same issue

thomasw7 avatar Sep 11 '17 12:09 thomasw7

Are you able to reproduce in a plunker?

willshowell avatar Sep 11 '17 13:09 willshowell

The situation is worse with beta.10. beta.11,though announced, is not published on npm, so beta.11 behavior cannot be determined.

In beta.8, one could leave out BrowserAnimationsModule, use BrowserModule and routing would work. In beta.10, BrowserModule only displays part of the page - header and footer using toolbar and grid-list. BrowserAnimationsModule is necessary to get the entire page to display.

Furthermore in beta.10 with BrowserAnimationsModule, when the back and forward browser buttons are used to navigate between the 2 pages, each browser button press adds another alternating vertically merged page. So after forward, back, forward, I have page1, page2, page1 in a single vertically merged page. The vertical merged page loses the sidenav in the home page that was there when the page loaded.

None of this happened in beta.8. Since then, I have just followed your instructions in Changelog and Getting Started.

Here's something that is not clear. Changelog for beta.10 says "All dash-case @Directive selectors are deprecated in favor of the camelCase equivalent", and gives "examples" but not a complete list. The next line says "md-input-container has been renamed to md-form-field" How is md-X to be identified as one versus the other, while scrolling through code making changes. No one keeps this stuff memorized in their head reliably. I have a lot of md-X in my code. None of them are in your "example" list. Do I need to change anything related to md-X statements? How do I know/tell while scrolling through code?

mLaird avatar Sep 12 '17 18:09 mLaird

It appears that this is working as expected. Here is a basic repro with routing working as expected.

If you are still seeing this issue, please provide a reproduction to investigate.

josephperrott avatar Sep 27 '17 22:09 josephperrott

I no longer have this behavior, but I have made many changes and the source of the problem is not clear. I have upgraded to beta.11, removed MaterialModule from the obvious places (and from some less obvious places) in my code, and changed a lot of material component import statements. ​

mLaird avatar Sep 27 '17 22:09 mLaird

I will close out this issue and feel free to open up a new one if you are able to isolate this issue and we will look into it.

josephperrott avatar Sep 27 '17 22:09 josephperrott

I was also seeing this issue in Angular 4.3.4 Angular-cli 1.2.8 Typescript 2.3.4

I have now upgraded to Angular 4.4.6 Angular-cli 1.4.9 Typescript 2.3.4 (still)

and I have installed the @angular/animations package, which was not a separate package in earlier releases. "@angular/animations": "^4.4.6",

This fixed the issue.

samrantmedia avatar Oct 31 '17 12:10 samrantmedia

I have upgraded to Angular 4.4.6 Angular-cli 1.4.9 Typescript 2.3.4

But still i have same issue, please help me

praveentnp avatar Nov 01 '17 13:11 praveentnp

Do you have the separate animations package installed? Perhaps make sure that it is not cached?

samrantmedia avatar Nov 01 '17 13:11 samrantmedia

No, I have installed Angular/Material, for that BrowserAnimationsModule/NoopAnimationsModule module required. After that, I have uninstalled Angular/Material, still, i am facing the same issue.

praveentnp avatar Nov 01 '17 14:11 praveentnp

How can I make sure that it is not cached?(Perhaps make sure that it is not cached?)

praveentnp avatar Nov 01 '17 14:11 praveentnp

Delete your node modules folder for the project. Close ide and reopen ide.

More thorough: npm uninstall -g angular-cli npm uninstall --save-dev angular-cli npm cache clean then run install commands/

I was seeing this issue without using angular material. It was another package that was using animations.

You are importing it like this? import {NoopAnimationsModule} from '@angular/platform-browser/animations';

samrantmedia avatar Nov 02 '17 10:11 samrantmedia

I spoke to soon. Further testing showed that I am also still getting this error.

samrantmedia avatar Nov 02 '17 12:11 samrantmedia

It was caused by a null reference exception. Once I resolved this null reference exception, I did not see this issue. With previous versions, this null reference exception did not cause the application to break. I suggest looking in the console to check for errors.

samrantmedia avatar Nov 02 '17 12:11 samrantmedia

Great findings, Thank you very much. I had spent last one week on this. Now its fixed by your suggestion.

praveentnp avatar Nov 04 '17 06:11 praveentnp

Thanks. A pleasure.

samrantmedia avatar Nov 06 '17 09:11 samrantmedia

Hi Folks, I am facing the same issue - as soon as i include the BrowserAnimationsModule/NoopAnimationsModule "@angular/animations": "^5.0.0",

I start seeing the html content getting appended to all routes i navigate to. Angular CLI: 1.5.0 Node: 8.5.0 OS: win32 x64 Angular: 5.0.0 ... animations, common, compiler, compiler-cli, core, forms ... http, language-service, platform-browser ... platform-browser-dynamic, router

@angular/cli: 1.5.0 @angular-devkit/build-optimizer: 0.0.32 @angular-devkit/core: 0.0.20 @angular-devkit/schematics: 0.0.35 @ngtools/json-schema: 1.1.0 @ngtools/webpack: 1.8.0 @schematics/angular: 0.1.0 typescript: 2.6.1 webpack: 3.8.1

tgupta694 avatar Nov 06 '17 11:11 tgupta694

Check your browser console, you will find exception thrown by your application, resolve it, then it will work fine.

praveentnp avatar Nov 12 '17 04:11 praveentnp

This thread leads us to an understanding that is NOT a good resolution. When there is a single undefined/null pointer exception any given SPA will break, until the page is refreshed.

abductedMind avatar Nov 13 '17 18:11 abductedMind

I agree. I don't think that this should be closed.

I have since removed the animations module, because I don't want to risk the app crashing if a null reference error happens.

samrantmedia avatar Nov 14 '17 10:11 samrantmedia