Home >Web Front-end >JS Tutorial >A brief discussion on the usage of slots in Angular

A brief discussion on the usage of slots in Angular

青灯夜游
青灯夜游forward
2021-03-17 09:54:312722browse

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.

A brief discussion on the usage of slots in Angular

<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

Related recommendations: "

angular tutorial"

Subcomponent

child

<div>
    <ng-content></ng-content>
    <ng-content select=&#39;.child&#39;></ng-content>
    <ng-content select=&#39;[name=child]&#39;></ng-content>
</div>
Parent component

<app-child>
    <p>默认插槽</p>
    <p class=&#39;child&#39;>类名选择插槽</p>
    <p name=&#39;child&#39;>属性选择插槽</p>
</app-child>
For more programming-related knowledge, please visit:

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!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete