Downgarde angular 2 directive or at least being able to use it in angular js

Viewed 265

I'm trying to use my ng2 directive in angularjs, but cannot get it to work. I've seen that downgradeComponent uses restric: 'E' for the angularjs directive, which means it's restricted to elements. Anyone knows how to deal with this problem?

I've tried simply using my directive in angular js, and it didn't work. I'm using UpgradeModule for hybrid bootstraping.

this is my directive.

@Directive({
    selector: '[test-directive]'
})
export class TestDirective implements OnInit {
    @Input("test-directive") testDirective: string;

    constructor(private el: ElementRef, private renderer: Renderer) {

    }

    ngOnInit() {
        console.log("color is = " + this.testDirective);
        this.renderer.setElementStyle(this.el.nativeElement, 'background-color', this.testDirective);
    }
}

I've tried using in AngularJS as an attribute (trying using it as [test-directive] and as test-directive.

Am I missing something here? Because I've searched the web and didn't found a lot of information regarding this problem.

1 Answers
Related