This article will introduce to you the use of Angular slots. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.
<span style="font-size: 18px;">Angular</span>
Use of slots
Use ng-content
Mainly with the help of select
If you don’t fill in anything, use it directly< ng-content></ng-content>
will display the default content passed by the parent component
<ng-content select='.child '></ng-content>
Uses the class name selector
##Use the attribute selector
angular tutorial"
Subcomponentchild
<div> <ng-content></ng-content> <ng-content select='.child'></ng-content> <ng-content select='[name=child]'></ng-content> </div>
<app-child> <p>默认插槽</p> <p class='child'>类名选择插槽</p> <p name='child'>属性选择插槽</p> </app-child>
Programming Video! !
The above is the detailed content of A brief discussion on the usage of slots in Angular. For more information, please follow other related articles on the PHP Chinese website!