我想在angularjs中使用我的ng2指令,但無法讓它工作。我已經看到downgradeComponent對angularjs指令使用限制:'E',這意味着它僅限於元素。任何人都知道如何處理這個問題?Downgarde角2指令或至少能夠在角js中使用它
我試過簡單地使用我的指令在角js中,它沒有工作。 我正在使用UpgradeModule進行混合引導。
這是我的指令。
@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);
}
}
我已經嘗試使用在AngularJS作爲一個屬性(因爲我在網上搜索試圖使用它作爲[測試指令]和測試指令。
我在這裏失去了一些東西?並沒有發現關於這個問題的大量信息。
這是我的角度教程示例https://plnkr.co/edit/jE4FTbnEWTuuYasXNvEX?p=preview https://angular.io/guide/upgrade#transcluding-angular-content-into-angularjs-component-directives – yurzui
你能重現你的問題嗎? – yurzui
在你的例子(yurzui)中,我沒有看到使用屬性,我會嘗試在你的例子中重現它。 –