0

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

ppovoski
  • 4,553
  • 5
  • 22
  • 28
Jazib
  • 1,200
  • 1
  • 16
  • 39
  • It works for me https://plnkr.co/edit/FOIyGX0cxLVCuBVaoUvg?p=preview I have also tried it on local machine – yurzui Dec 26 '16 at 14:30
  • Yes, works in plunker but not locally. Do you think it might have something to do with package versions? – Jazib Dec 26 '16 at 21:26

1 Answers1

1

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.

Jazib
  • 1,200
  • 1
  • 16
  • 39