[Angular] Learn Angular Multi-Slot Content Projection
Now for au-modal component, we pass in tow component though contenct projection:
<au-modal
class="auth-modal"
#modal
*auModalOpenOnClick="[loginButton, signUpButton]"
[closeOnClickOutside]="true"
[closeOnEsc]="true">
<i class="fa fa-times" (click)="modal.close()"></i>
<au-tab-panel>
<!-- modal body-->
</au-tab-panel>
</au-modal>
One is 'au-tab-panel' which contains all the content body for modal. Another is 'i' tag, repersent a close icon.
Now both are passed in though content projection, so au-modal component, we need to know how to project two components into correct places.
au-modal component:
<div class="modal-overlay" (click)="onClick()"> <div class="modal-body" (click)="cancelCloseModal($event)"> <div class="close-icon">
<ng-content select="i"></ng-content>
</div> <ng-container *ngIf="body; else projectionBody">
<ng-container *ngTemplateOutlet="body"></ng-container>
</ng-container> <ng-template #projectionBody>
<ng-content></ng-content>
</ng-template> </div> </div>
Here using 'select' attr for ng-content, it will take the projection body with the correct selector. In this case, is 'i' tag.
The rest content which don't have any selector will goes into:
<ng-template #projectionBody>
<ng-content></ng-content>
</ng-template>
And this ng-template won't shows up until:
*ngIf="body; else projectionBody"
[Angular] Learn Angular Multi-Slot Content Projection的更多相关文章
- [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 ...
- [Angular] Configurable Angular Components - Content Projection and Input Templates
We are going to have a modal component: <au-modal > </au-modal> And we can pass default ...
- [Angular] Content Projection with ng-content
For example there is tow form compoennts on the page, and what we want to do is reusing the form com ...
- angular 2 angular quick start Could not find HammerJS
Angular2 的material中 引用了 hammerjs,遇到Could not find HammerJS错误,正确的步骤如下: 需要在如下位置增加 对material 和 hammerjs ...
- ASP.NET Core 2.1 Web API + Identity Server 4 + Angular 6 + Angular Material 实战小项目视频
视频简介 ASP.NET Core Web API + Angular 6的教学视频 我是后端开发人员, 前端的Angular部分讲的比较差一些, 可以直接看代码!!!! 这是一个小项目的实战视频, ...
- [Angular] Learn How To Use ng-template Inputs
For example, we have a modal component, it can config that using ng-template as a configurable templ ...
- [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 ...
- 简话Angular 03 Angular内置表达式大全
一句话: 大多数html标签属性和事件都有一个对应的ng指令 说明:这些指令和原生html最大的区别就是可以动态更新.比如一个div的样式用ng-class后,我们就可以随意应用css class. ...
- [Angular] Refactor Angular Component State Logic into Directives
Allow the base toggle to be a tag (<toggle>) or attribute (<div toggle>). The <toggle ...
随机推荐
- IDC机房KVM应用案例分析
IDC机房KVM应用案例分析 一.背景介绍 随着信息技术的发展,各行各业都在马不停蹄的开展着各自的信息化建设步伐.对于设计制造创新科技产品为运行主业的设计院而言,内部IT基础设备与机房管理结构的完善与 ...
- SortedDictionary<TKey, TValue> 类 表示根据键进行排序的键/值对的集合。
SortedDictionary<TKey, TValue> 类 表示根据键进行排序的键/值对的集合. SortedDictionary<TKey, TValue> 中的每 ...
- javafx checkbox
public class EffectTest extends Application { public static void main(String[] args) { launch(args); ...
- C/C++(基础编码-补码详解)
两个数的交换 1.引入第三者. 2.求和运算,求差.(这样会产生内存溢出) 3.异或运算 a = a^b; b = a^b; a = a^b; 8b(bit位) = 1B(Byte=字节)//最小单位 ...
- double 失真例子
public static void main(String[] args) { // TODO Auto-generated method stub double ab=821.20; dou ...
- 安卓使用WebView下载文件,安卓实现软件升级功能
由于调用系统默认浏览器下载更新,造成用户体验非常不好,所以决定在webview中直接下载系统更新.然后直接安装. 由于要下载,所以必须用webview,联网权限这里不说了,直接写在manifafest ...
- 深入理解javascript之原型
理解原型 原型是一个对象.其它对象能够通过它实现属性继承. 不论什么一个对象都能够成为继承,全部对象在默认的情况下都有一个原型.由于原型本身也是对象,所以每一个原型自身又有一个原型. 不论什么一个对象 ...
- IPv6地址表示方法详解
IPv6是互联网协议的第六版:最初它在IETF的 IPng选取过程中胜出时称为互联网新一代网际协议(IPng),IPv6是被正式广泛使用的第二版互联网协议. 现有标准IPv4只支持大概40亿(4×10 ...
- Objective-C基础笔记(8)Foundation常用类NSString
一.创建字符串的方法 void stringCreate(){ //方法1 NSString *str1 = @"A String!"; //方法2 NSString *str2 ...
- 深入理解Linux启动过程
深入理解Linux启动过程 本文详细分析了Linux桌面操作系统的启动过程,涉及到BIOS系统.LILO 和GRUB引导装载程序,以及bootsect.setup.vmlinux等映像文件 ...