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的更多相关文章

  1. [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 ...

  2. [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 ...

  3. [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 ...

  4. angular 2 angular quick start Could not find HammerJS

    Angular2 的material中 引用了 hammerjs,遇到Could not find HammerJS错误,正确的步骤如下: 需要在如下位置增加 对material 和 hammerjs ...

  5. ASP.NET Core 2.1 Web API + Identity Server 4 + Angular 6 + Angular Material 实战小项目视频

    视频简介 ASP.NET Core Web API + Angular 6的教学视频 我是后端开发人员, 前端的Angular部分讲的比较差一些, 可以直接看代码!!!! 这是一个小项目的实战视频, ...

  6. [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 ...

  7. [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 ...

  8. 简话Angular 03 Angular内置表达式大全

    一句话: 大多数html标签属性和事件都有一个对应的ng指令 说明:这些指令和原生html最大的区别就是可以动态更新.比如一个div的样式用ng-class后,我们就可以随意应用css class. ...

  9. [Angular] Refactor Angular Component State Logic into Directives

    Allow the base toggle to be a tag (<toggle>) or attribute (<div toggle>). The <toggle ...

随机推荐

  1. 83.const与类

    const常量对象,无法改变数据,只能引用尾部带const方法 类的成员如果是const,可以默认初始化,也可以构造的初始化,不可在构造函数内部初始化 类中的const成员,无法直接修改,可以间接修改 ...

  2. Zabbix自动发现与自动注册.

    一, 自动发现与自动注册 自动发现? 当场景中出现要添加很多台主机的时候,一台台添加难免太过于繁琐,zabbix提供自动注册,自动发现,可以实现主机的批量添加, zabbix的发现包括三种类型: # ...

  3. GCC中-fpic解惑(转载)

    参考: 1.<3.18 Options for Code Generation Conventions>2.<Options for Linking>3.<GCC -fP ...

  4. UVA - 10674-Tangents

     题意:给出两个圆,求它们的公切线,并依照一定格式输出 做法:模拟 代码: #include<iostream> #include<map> #include<str ...

  5. [分享]ip地址爬取过滤的shell

    http://www.hbbzy.me/分享ip地址爬取过滤的shell #!/bin/base #ip zhi地址匹配 #获取最新的ip地址 #author:haifeng #wget ftp:// ...

  6. js34

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/stri ...

  7. worktools-源码下拉问题

    今天下拉源码的时候,出现了一个问题,就是当地的内容跟仓库的内容冲突,导致merge冲突.这时候CC指令不能用.然后希望通过checkout到其他分支,然后cc掉的.结果没办法切换到其他分支,一直停留在 ...

  8. SQL2012的新分页方法

    SELECT BusinessEntityID , FirstName , LastName FROM Person.Person ORDER BY BusinessEntityID OFFSET ( ...

  9. 体验SUSE (附视频演示)

    操作动画演示 本文出自 "李晨光原创技术博客" 博客,谢绝转载!

  10. ZOJ QS Network

    QS Network Time Limit: 2 Seconds      Memory Limit: 65536 KB Sunny Cup 2003 - Preliminary Round Apri ...