博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[Angular 2] Select From Multiple Nested Angular 2 Elements
阅读量:4355 次
发布时间:2019-06-07

本文共 1163 字,大约阅读时间需要 3 分钟。

You have complete control over the elements you nest inside of your component instance by using selectors to access and rearrange them. Selecting allows you reconstruct the elements in whatever order you like so you can visual customize the content passed in.

 

You can pass multi elmenents into ng-content:

home.ts:

@Component({    selector: 'home',    template: `

Title

Some content

Footer

`})

 

widget-two.ts:

@Component({    selector: 'widget-two',    styles:[`:host{    display: block;    border: 3px solid red;}`],    template: `

Above

Below

`})

So all three element will be passed into ng-content:

Title

Some content

Footer

 

ng-content can add "select" attr, you can use "element tag", "attr", "class / id":

@Component({    selector: 'home',    template: `

Title

Some content

Footer

`})
@Component({    selector: 'widget-two',    styles:[`:host{    display: block;    border: 3px solid red;}`],    template: `

Above

footer-->
Title -->

Below

`})

 

转载于:https://www.cnblogs.com/Answer1215/p/5896305.html

你可能感兴趣的文章
web.xml文件的作用
查看>>
linux下oracle调试小知识
查看>>
alert弹出窗口,点击确认后关闭页面
查看>>
oracle问题之数据库恢复(三)
查看>>
单点登陆(SSO)
查看>>
HR,也确实“尽职尽责”
查看>>
MaxComputer 使用客户端配置
查看>>
20190823 顺其自然
查看>>
阅读《余生有你,人间值得》有感
查看>>
每日英语
查看>>
SpringCloud+feign 基于Springboot2.0 负载均衡
查看>>
【BZOJ5094】硬盘检测 概率
查看>>
mac上n次安装与卸载mysql
查看>>
Python之单元测试——HTMLTestRunner
查看>>
WebNotes(PHP、css、JavaScript等)
查看>>
C++:文件的输入和输出
查看>>
Http协议、Tomcat、servlet
查看>>
Spring Boot (11) mybatis 关联映射
查看>>
macOS 下安装tomcat
查看>>
字符串格式化复习笔记
查看>>