*The children element which are located inside of its template of a component are called *view children *. On the other hand, **elements which are used between the opening and closing tags of the host element of a given component are called *content…
原文 https://www.jianshu.com/p/5ab619e576ea 大纲 1.认识ViewChild 2.认识ContentChild 3.ViewChild与ContentChild的联系和区别 认识ViewChild /* angular中文文档的说明 You can use ViewChild to get the first element or the directive matching the selector from the view DOM. If the v…
ElementRef: In Angular2 Doc, it suggest to "avoid" using ElementRef. It access DOM directly, can easily be attacked. import {Component, OnInit, ViewChild, Renderer, ElementRef} from '@angular/core'; @Component({ moduleId: module.id, selector: 'w…
Content is what is passed as children. View is the template of the current component. The view is initialized before the content and ngAfterViewInit() is therefore called before ngAfterContentInit(). @Component({ selector: 'parent-cmp', template: '<d…