[Angular 2] Share Template Content In Another Template With Content Projection <ng-content>
Angular 1 provided a mechanism to place content from your template inside of another template called transclusion. This concept has been brought into Angular 2 and was renamed to content projection and given super powers.
In this lesson learn how to setup content projection and upgrade it to support multiple projections with encapsulated functionality.
ng-content, just like Angular1 transclude, in ng-content, you can add 'select' attr to do content projection:
<ng-content select=".header"></ng-content>
<div class="result-list">
<md-list >
<md-list-item *ngFor="let item of searchResult">
{{item}}
</md-list-item>
<md-list-item *ngIf="searchResult?.length === 0">No result...</md-list-item>
<md-list-item *ngIf="!searchResult">List here...</md-list-item>
</md-list>
</div>
<ng-content select="footer"></ng-content>
Using:
<result-list [keys]="items" [urls]="urls" class="list">
<div class="header">Search result: </div>
<footer>End...</footer>
</result-list>
[Angular 2] Share Template Content In Another Template With Content Projection <ng-content>的更多相关文章
- Deferred content load was not performed. To provide the content, subscribe to the View's QueryControl event
{"Deferred content load was not performed. To provide the content, subscribe to the View's Quer ...
- content is not supported outside 'script" or asp content' region
https://stackoverflow.com/questions/48915080/asp-net-content-is-not-supported-outside-the-script-or- ...
- ES6, Angular,React和ABAP中的String Template(字符串模板)
String Template(字符串模板)在很多编程语言和框架中都支持,是一个很有用的特性.本文将Jerry工作中使用到的String Template的特性做一个总结. ES6 阮一峰老师有一个专 ...
- [Angular 2] Exposing component properties to the template
Showing you how you can expose properties on your Controller to access them using #refs inside of yo ...
- Azure ARM (5) ARM Template初探 - 本地JSON Template文件(1)
<Windows Azure Platform 系列文章目录> Azure ARM (1) 概览 Azure ARM (2) 概览 Azure ARM (3) ...
- [Angular 2] Share a Service Across Angular 2 Components and Modules
Services are used to share data between components. They follow a module pattern that allows you to ...
- <转载>模板声明中template <typename T>和template <class T>
原文地址http://blog.csdn.net/bug07250432/article/details/10150625 在c++Template中很多地方都用到了typename与class这两个 ...
- 模板专业化和模板偏特样片(template specialization and partial template specialization)
测试环境: win7 64 g++ 4.8.1 /*************************************************************************** ...
- Django——如何使用Template以及如何向template传递变量
如何使用模板系统 在Python代码中使用Django模板的最基本方式如下: 可以用原始的模板代码字符串创建一个 Template 对象, Django同样支持用指定模板文件路径的方式来创建 Temp ...
随机推荐
- CSS 文本样式
1. 文本样式 text <!--文本颜色color --> .text {color:red;} 2. 文本对齐方式 text-align <style> .text ...
- ArcGIS Engine检索要素集、要素类和要素
转自原文 ArcGIS Engine检索要素集.要素类和要素 /// <summary> /// 获取所有要素集 /// </summary> /// <param na ...
- [Angular] Make a chatbot with DialogFlow
Register a account on https://console.dialogflow.com/api-client/ "Creat a intent" -- you c ...
- UVA - 10674-Tangents
题意:给出两个圆,求它们的公切线,并依照一定格式输出 做法:模拟 代码: #include<iostream> #include<map> #include<str ...
- Java IO:SocketChannel和Selector在ZooKeeper中应用
转载请注明出处:jiq•钦's technical Blog 假设不了解SocketChannel和Selector.请先阅读我的还有一篇博文:点击打开链接 ZooKeeper的启动从QuorumPe ...
- Linux - 用 Konstruct 安装 KDE 3.x
make-kde3.x Linux - 用 Konstruct 安装 KDE 3.x 找个截图工具 khtml2png (http://khtml2png.sourceforge.net/), 现在都 ...
- 44.delete用法
声明+delete:函数禁止使用.可以使一个类禁止释放
- Linux库文件路径的添加
库文件在连接(静态库和共享库)和运行(仅限于使用共享库的程序)时被使用,其搜索路径是在系统中进行设置的.一般 Linux 系统把 /lib 和 /usr/lib 两个目录作为默认的库搜索路径,所以使用 ...
- 根据ID和parentID利用Java递归获取全路径名称
如下图所示,本文参考资源:https://jie-bosshr.iteye.com/blog/1996607 感谢大佬的无私奉献. 思路: 定义一个方法getParentName参数为int类型的c ...
- django遇到的那些古怪问题
AssertionError: .accepted_renderer not set on Response 出错原因,没有在合法的方法内使用 response 响应,之前在dispatch内直接re ...