I am trying to use my ng2 directive in angularjs but cannot make it work. I saw that downgradeComponent uses restric: 'E' for the angularjs directive, which means that it is limited to elements. Does anyone know how to deal with this problem?
I tried just using my directive in angular js and it didn't work. I am using UpgradeModule for hybrid bootstrap.
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 tried using AngularJS as an attribute (trying to use it as [test-directive] and as a test directive.
Am I missing something? Because I searched the Internet and did not find much information about this problem.