[Angular] @ContentChildren and QueryList】的更多相关文章

We have looked at @ContentChild in article(http://www.cnblogs.com/Answer1215/p/6414657.html). Now let's how to query multi children by using @ContentChildren and QueryList. First of all, let's add few more auth-remember component into our form compon…
Allow more than one child component of the same type. Allow child components to be placed within the views of other custom components. In previous post, we have seen how to use @ContentChild to asscomplish compound component implementation. It has so…
Previously we have tab-panel template defined like this: <ul class="tab-panel-buttons" *ngIf="tabs"> <li [ngClass]="{selected: tab.selected}" (click)="selectTab(tab)" *ngFor="let tab of tabs;">…
1. ng-template 形式:<ng-template>...</ng-template> 默认ng-template中的内容会隐藏; 可通过[ngIf]来控制内容显示隐藏: 此标签不会影响原本html结构: html: <ng-template [ngIf]="true"> this is template! </ng-template> 浏览器输出: 浏览器调试窗口 2. template 形式:<template>…
原文链接 Understanding ViewChildren, ContentChildren, and QueryList in Angular 使用场景 有时候,我们想要在父组件中访问它的子组件.在Angular中可以使用ViewChildren ViewChild ContentChildren 来实现对子组件的访问. 假设,我们封装了一个Alert子组件 // alert.component.html <h1 (click)="alert()">{{type}}&…
In previous artical, we introduce the how to use *ngFor. The limitation for previous solution to display all the heros is we hard cord all heros in our heroes component. First, in real world app, we cannot hard cord;  Seond, even we don't hard code,…
Web Component 在介绍Angular Component之前,我们先简单了解下W3C Web Components 定义 W3C为统一组件化标准方式,提出Web Component的标准. 每个组件包含自己的html.css.js代码. Web Component标准包括以下四个重要的概念: Custom Elements(自定义标签):可以创建自定义 HTML 标记和元素: HTML Templates(HTML模版):使用 概括来说就是,可以创建自定义标签来引入组件是前端组件化的…
@angular/ckd 是 ng 对于 ui 组建的基础架构. 是由 material 团队开发与维护的, 之所以会有 cdk 看样子是因为在开发 material 的时候随便抽象一个层次出来给大家用. 这系列是我按照官网教程和查了一下 angular/material 源码的学习笔记. 1. KeyManger  运用场景是 select, menu 这种有 list options 的组件, 负责处理键盘上下按钮时 option active 的逻辑 ng 提供了 3 个类 ListKey…
Angular中的装饰器是一个函数,它将元数据添加到类.类成员(属性.方法)和函数参数. 用法:要想应用装饰器,把它放在被装饰对象的上面或左边. Angular使用自己的一套装饰器来实现应用程序各部件之间的相互操作. 这个地方是前面几个模块(Modules), 指令(Diretives).组件(Components).依赖注入(Dependency Injection)等从装饰器这个侧面的整理. 你需要做的: 1.搞清楚理解TypeScript的装饰器原理. 2.搞清楚这里面每一个装饰器的作用,…
contentchild // 使用方法 git clone https://git.oschina.net/mumu-osc/learn-component.git cd learn-component git pull origin contentchild npm install ng serve <!-- test-content-child.component.html --> <div class="panel panel-primary"> <…