docs(core): extract how to examples
This commit is contained in:
parent
2c42a50fc3
commit
5972fdc817
|
@ -0,0 +1,24 @@
|
||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright Google Inc. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by an MIT-style license that can be
|
||||||
|
* found in the LICENSE file at https://angular.io/license
|
||||||
|
*/
|
||||||
|
|
||||||
|
// #docregion HowTo
|
||||||
|
import {AfterContentInit, Component, ContentChildren, Directive, QueryList} from '@angular/core';
|
||||||
|
|
||||||
|
@Directive({selector: 'child-directive'})
|
||||||
|
class ChildDirective {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Directive({selector: 'someDir'})
|
||||||
|
class SomeDir implements AfterContentInit {
|
||||||
|
@ContentChild(ChildDirective) contentChild;
|
||||||
|
|
||||||
|
ngAfterContentInit() {
|
||||||
|
// contentChild is set
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// #enddocregion
|
|
@ -0,0 +1,24 @@
|
||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright Google Inc. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by an MIT-style license that can be
|
||||||
|
* found in the LICENSE file at https://angular.io/license
|
||||||
|
*/
|
||||||
|
|
||||||
|
// #docregion HowTo
|
||||||
|
import {AfterContentInit, Component, ContentChildren, Directive, QueryList} from '@angular/core';
|
||||||
|
|
||||||
|
@Directive({selector: 'child-directive'})
|
||||||
|
class ChildDirective {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Directive({selector: 'someDir'})
|
||||||
|
class SomeDir implements AfterContentInit {
|
||||||
|
@ContentChildren(ChildDirective) contentChildren: QueryList<ChildDirective>;
|
||||||
|
|
||||||
|
ngAfterContentInit() {
|
||||||
|
// contentChildren is set
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// #enddocregion
|
|
@ -0,0 +1,24 @@
|
||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright Google Inc. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by an MIT-style license that can be
|
||||||
|
* found in the LICENSE file at https://angular.io/license
|
||||||
|
*/
|
||||||
|
|
||||||
|
// #docregion HowTo
|
||||||
|
import {AfterViewInit, Component, Directive, QueryList, ViewChild} from '@angular/core';
|
||||||
|
|
||||||
|
@Directive({selector: 'child-directive'})
|
||||||
|
class ChildDirective {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Component({selector: 'someCmp', templateUrl: 'someCmp.html'})
|
||||||
|
class SomeCmp implements AfterViewInit {
|
||||||
|
@ViewChild(ChildDirective) child: ChildDirective;
|
||||||
|
|
||||||
|
ngAfterViewInit() {
|
||||||
|
// child is set
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// #enddocregion
|
|
@ -0,0 +1,24 @@
|
||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright Google Inc. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by an MIT-style license that can be
|
||||||
|
* found in the LICENSE file at https://angular.io/license
|
||||||
|
*/
|
||||||
|
|
||||||
|
// #docregion HowTo
|
||||||
|
import {AfterViewInit, Component, Directive, QueryList, ViewChildren} from '@angular/core';
|
||||||
|
|
||||||
|
@Directive({selector: 'child-directive'})
|
||||||
|
class ChildDirective {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Component({selector: 'someCmp', templateUrl: 'someCmp.html'})
|
||||||
|
class SomeCmp implements AfterViewInit {
|
||||||
|
@ViewChildren(ChildDirective) viewChildren: QueryList<ChildDirective>;
|
||||||
|
|
||||||
|
ngAfterViewInit() {
|
||||||
|
// viewChildren is set
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// #enddocregion
|
Loading…
Reference in New Issue