1
我正在將AngularJS 1.6組件遷移到Angular 4.3.2,並且需要在組件標籤上強制執行id
屬性。然而,爲了與現有的NG1組件NG2 +的工作,你需要降級他們:如何在角度2+降級的組件上強制使用id?
angular.module('myNg1module')
.directive('myComponent', downgradeComponent({component: MyComponent}))
在編譯的輸出,這使得Angular generate a dynamic id它覆蓋了你自己的id
。例如輸出將是:
<my-component id="NG2_UPGRADE_27_0"></my-component>
我試了一下沒有成功:
- 設置在模板中
id
屬性:<my-component id="my-id">
但輸出將簡單地覆蓋它; - 在模板中設置ID爲
[attr.id]
:<my-component [attr.id]="my-id">
但這會被忽略。
你可以創建一個plunker嗎? –