Home > Web Front-end > JS Tutorial > body text

A brief discussion on the usage of slots in Angular

青灯夜游
Release: 2021-03-17 09:54:31
forward
2662 people have browsed it

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>
Copy after login
Parent component

<app-child>
    <p>默认插槽</p>
    <p class=&#39;child&#39;>类名选择插槽</p>
    <p name=&#39;child&#39;>属性选择插槽</p>
</app-child>
Copy after login
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!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!