3

Trying to make MDL working with Angular2.

With shadow DOM emulation angular encapsulates all css and html which it gains from code. But when I use componentHandler.upgradeElement(), it creates new elements with no encapsulation.

What should I do to make it encapsulated too?

Lodin
  • 2,028
  • 2
  • 18
  • 29

1 Answers1

1

Adding this simple directive mdl element!

import {Component, ElementRef } from 'angular2/core';
declare var componentHandler: any;


@Component({
    selector: '[mdl]',
    template: `<ng-content></ng-content>`
})



    export class MdlComponent {

    constructor(public el: ElementRef) {

        MdlComponent.mdlWrapper(el);

    }

    static mdlWrapper(element: ElementRef) {

        componentHandler.upgradeElement(element.nativeElement);
    }
}
Maks3w
  • 6,014
  • 6
  • 37
  • 42