我尝试使用嵌入 n angular6 并且无法使我的范围变直。
<component-smart1
[someObject]="myObject"
[someService]="saidService">
<component-dumb-1
[specificObject]="getSpecificObject()"></component-dumb-1>
<component-dumb-2
[specificObject]="getSpecificObject()"
(someEvent)="handleEvent()"></component-dumb-2>
</component-smart1>
现在我希望哑组件(component-dumb-1
,component-dumb-2
)使用智能组件(component-smart1
)范围/方法/属性。
我的目标是能够在嵌入中用不同的组件组成不同的变体,所有这些都使用智能组件中的相同方法。例如:
<component-smart1
[someObject]="myObject"
[someService]="saidService">
<component-dumb-1
[specificObject]="getSpecificObject()"></component-dumb-1>
<component-dumb-2
[specificObject]="getSpecificObject()"
(someEvent)="handleEvent()"></component-dumb-2>
<component-dumb-3
[specificObject]="getSpecificObject()"
(someOtherEvent)="handleOtherEvent()"></component-dumb-3>
</component-smart1>
这可能吗?