[Angular 2] Select From Multiple Nested Angular 2 Elements
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: `
<widget-two>
<h2>Title</h2>
<div>Some content</div>
<h3>Footer</h3>
</widget-two>
`
})
widget-two.ts:
@Component({
selector: 'widget-two',
styles:[`
:host{
display: block;
border: 3px solid red;
}
`],
template: `
<h2>Above</h2>
<ng-content ></ng-content>
<h2>Below</h2>
`
})
So all three element will be passed into ng-content:
<h2>Title</h2>
<div>Some content</div>
<h3>Footer</h3>
ng-content can add "select" attr, you can use "element tag", "attr", "class / id":
@Component({
selector: 'home',
template: `
<widget-two>
<h2 header>Title</h2> <!-- attr -->
<div class="content">Some content</div> <!-- class -->
<h3>Footer</h3> <!-- tag -->
</widget-two>
`
})
@Component({
selector: 'widget-two',
styles:[`
:host{
display: block;
border: 3px solid red;
}
`],
template: `
<h2 >Above</h2>
<ng-content select="h3"></ng-content> <!-- tag h3 --> footer-->
<ng-content select="[header]"></ng-content> <!--attr h2 --> Title -->
<ng-content select=".content"></ng-content> <!-- class--->
<h2>Below</h2>
`
})
[Angular 2] Select From Multiple Nested Angular 2 Elements的更多相关文章
- angular实现select的ng-options4
ng实现简单的select <div ng-controller="ngSelect"> <select ng-model="vm.selectVal& ...
- [Angular 2 Router] Configure Your First Angular 2 Route
Using the Angular 2 router requires defining routes, passing them in to the RouterModule.forRoot and ...
- 【Angular专题】——(1)Angular,孤傲的变革者
目录 一. 漫谈Angular 二. 如果你还在使用Angularjs 三. 我计划这样学习Angular技术栈 一. 漫谈Angular Angular,来自Google的前端SPA框架,与Reac ...
- [Angular] Use Angular components in AngularJS applications with Angular Elements
When migrating AngularJS (v1.x) applications to Angular you have different options. Using Angular El ...
- NEST - How can i do multiple nested aggregation?
question: How can I do multiple nested aggregation? I have tried something like this: Aggregations(x ...
- select标签multiple属性的用法
前些日子公司让做一个功能模块.对于里面一个小功能费了些周折,现将其总结一下: 一.实现效果: watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvZ2FvaHVh ...
- Angular 从入坑到挖坑 - Angular 使用入门
一.Overview angular 入坑记录的笔记第一篇,完成开发环境的搭建,以及如何通过 angular cli 来创建第一个 angular 应用.入坑一个多星期,通过学习官方文档以及手摸手的按 ...
- [从 0 开始的 Angular 生活]No.38 实现一个 Angular Router 切换组件页面(一)
前言 今天是进入公司的第三天,为了能尽快投入项目与成为团队可用的战力,我正在努力啃官方文档学习 Angular 的知识,所以这一篇文章主要是记录我如何阅读官方文档后,实现这个非常基本的.带导航的网页应 ...
- Angular项目构建指南 - 不再为angular构建而犹豫不决(转)
如果你不知道什么是Angular或者根本没听说过,那么我接下来所说的对你来说毫无益处,不过如果你打算以后会接触Angular或者干脆要涨涨姿势~读下去还是有点用的. Angular和它之前所出现的其余 ...
随机推荐
- 捣蛋phpwind控制器注入
在PwBaseController 里面,会有这个方法的存在 /** * action Hook 注册 * * @param string $registerKey 扩展点别名 * @param Pw ...
- C++11 多线程
C++11开始支持多线程编程,之前多线程编程都需要系统的支持,在不同的系统下创建线程需要不同的API如pthread_create(),Createthread(),beginthread()等,使用 ...
- Python学习第二天数组
1:Python定义数组:a=[0,1,2,3,4] ; 打印数组list(a); 这时:a[0]=0, a[1]=1, a[[2]=2...... 1.1:如果想定义一个很长的数组可以用到pyt ...
- 分区表,桶表,外部表,以及hive一些命令行小工具
hive中的表与hdfs中的文件通过metastore关联起来的.Hive的数据模型:内部表,分区表,外部表,桶表受控表(managed table):包括内部表,分区表,桶表 内部表: 我们删除表的 ...
- Codeforces Educational Codeforces Round 15 D. Road to Post Office
D. Road to Post Office time limit per test 1 second memory limit per test 256 megabytes input standa ...
- RHAS Linux下架构Lotus Domino详解(附视频)
此处下载操作视频:RHAS Linux下架构Lotus Domino 6.5视频教程 在rhas下架构Lotus Domino 汉化 650) this.width=650;" o ...
- What are some good resources for learning about Artificial Neural Networks
http://stackoverflow.com/questions/478947/what-are-some-good-resources-for-learning-about-artificial ...
- js上三行下三行和添加多个附件
function addTr(num) { no ++; var obj = document.getElementById(tableID); var oneRow = obj.insertRow( ...
- POJ1948Triangular Pastures(DP)
POJ1948http://poj.org/problem?id=1948 题目大意就是说给你n个木棍让你用它们摆成一个三角形 使得这个三角形的面积最大. 这个题我之前想的时候一直纠结怎么通过之前的 ...
- SQLServer2005 提示 '其他会话正在使用事务的上下文'
MSDN上看了一下说是sql server 2005不支持在分布式事务处理中存在指向本地的链接服务器(环回链接服务器) 这个是官方的回答 个人认为,应该是在事务中,使用了链接服务器访问进行跨库访问引起 ...