[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 ...
随机推荐
- javafx style and cssFile
public class EffectTest extends Application { public static void main(String[] args) { launch(args); ...
- Index was out of range
Index was out of range. Must be non-negative and less than the size of the collection. Parameter nam ...
- JavaScript--数据结构与算法之集合
集合(Set):是一种包含不同元素的数据结构. 重要特性:1.集合中的成员时无序的:2.集合中不允许相同的成员存在. 使用场景:用于存储一些独一无二的元素. 1 集合的定义:(和高中数学中的集合一样) ...
- JavaScript笔记(2)
-->变量的定义 1.取得并使用值是所有程序设计中的要点 2.JS中的变量是没有类型的,在JS中只有值才持有类型,变量所持有的是其对应值的类型. 3.变量的取名要符合标识符的规则: (1)一个J ...
- lastb---显示用户错误的登录列表
lastb命令用于显示用户错误的登录列表,此指令可以发现系统的登录异常.单独执行lastb命令,它会读取位于/var/log目录下,名称为btmp的文件,并把该文件内容记录的登入失败的用户名单,全部显 ...
- 【Educational Codeforces Round 36 B】Browser
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 分类在区间里面和左边.右边三种情况. 看看l的左边有没有标签.r的右边有没有标签. 就能做完了. [代码] #include < ...
- 【习题 8-10 UVA - 1614】Hell on the Markets
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 证明:前i个数一定能凑够1..sum[i]中的所有数字 i=1时显然成立. 现在假设i>=2时结论成立 即前i个数字能凑出1. ...
- (九)unity4.6学习Ugui中文文档-------參考-UGUI Rect Transform
大家好.我是孙广东. 转载请注明出处:http://write.blog.csdn.net/postedit/38922399 更全的内容请看我的游戏蛮牛地址:http://www.unit ...
- Date类的用法
package example; import java.text.DateFormat; import java.text.ParseException; import java.text.Simp ...
- 动态库dll使用module.def文件导出函数(像静态库一样使用)
1.新建文件module.def. 2.动态库工程上右键->属性->链接器->输入->模块定义文件编辑它写入module.def 3.下面为module.def实例(smart ...