Skip to content Skip to sidebar Skip to footer

Angular2 With Material Design Lite

I have added the following bit of code in my angular2 app to help MDL re-register the components when moving around the app... ngAfterViewInit() { componentHandler.upgradeDom()

Solution 1:

It should help you to add

declarevarcomponentHandler: any;

at the top of your code. Please refer to the corresponding handbook section on Working with Other JavaScript Libraries in TypeScript.

Solution 2:

if you are using cli.angular tool for generating your app do this, so that no need to duplicate the code everywhere.

  1. add below line into typings.d.ts file

    declarevarcomponentHandler: any; 
  2. reference the file into your component file as below

    ///<reference path="../typings.d.ts" />

Solution 3:

I guess you need to add

declare componentHandler;
componentHandler.upgradeDom();

See also Calling JavaScript directly from TypeScript

Post a Comment for "Angular2 With Material Design Lite"