Angular2 Material SnackBar integration problems

574 views Asked by At

I am trying to integrate Material Snackbar in my angular2 app.

I have already succesfully integrated ProgressBar from the same library successfully but running into errors with SnackBar.

Here's how I am integrating SnackBar

(relevant) app.module.ts:

imports: [
    BrowserModule,
    HttpModule,
    FormsModule,
    CoreModule,
    UsersModule,
    AppRoutingModule,
    MaterialModule.forRoot(),
],

(relevant) app.component.ts:

  constructor(private route: ActivatedRoute,
            private router: Router,
            private snackBar: MdSnackBar,
            private viewContainerRef: ViewContainerRef) {
}

// this method is bound to a simple button in template
showSnack() {
    this.snackBar.open("Showing Snack", "Yayyy!");
}

Upon clicking that showSnack button, I get this error:

ORIGINAL EXCEPTION: view.animationContext.getAnimationPlayers is not a function

A more detailed stacktrace: enter image description here

1

There are 1 answers

0
Jazib On BEST ANSWER

I don't know why, but it was an issue with package versions.

This problem was on Material 2.0.0-alpha.11-3 while my angular is on 2.2.0.

Updating material library to 2.0.0-beta.1 fixed my problem.