docs(core): update code sample for "outputs" attribute (#31199)
The current code sample for (directive) "outputs" attribute is incorrect as it does not provide the usage of "outputs" attribute rather it provides the usage of "exportAs" attribute. This commit update the code sample by correcting the code sample with correct usage of "outputs" attribute. Fixes https://github.com/angular/angular/issues/29523 Related work https://github.com/angular/angular/pull/30014 This commit continues from the unfinished (https://github.com/angular/angular/pull/30014#issuecomment-485419124, https://github.com/angular/angular/issues/29523#issuecomment-497333146) work. PR Close #31199
This commit is contained in:
parent
280e8563f0
commit
ae1ac45981
|
@ -163,18 +163,25 @@ export interface Directive {
|
||||||
* ### Example
|
* ### Example
|
||||||
*
|
*
|
||||||
* ```typescript
|
* ```typescript
|
||||||
* @Directive({
|
* @Component({
|
||||||
* selector: 'child-dir',
|
* selector: 'child-dir',
|
||||||
* exportAs: 'child'
|
* outputs: [ 'bankNameChange' ]
|
||||||
|
* template: `<input (input)="bankNameChange.emit($event.target.value)" />`
|
||||||
* })
|
* })
|
||||||
* class ChildDir {
|
* class ChildDir {
|
||||||
|
* bankNameChange: EventEmitter<string> = new EventEmitter<string>();
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* @Component({
|
* @Component({
|
||||||
* selector: 'main',
|
* selector: 'main',
|
||||||
* template: `<child-dir #c="child"></child-dir>`
|
* template: ` {{ bankName }} <child-dir (bankNameChange)="onBankNameChange($event)"></child-dir>`
|
||||||
* })
|
* })
|
||||||
* class MainComponent {
|
* class MainComponent {
|
||||||
|
* bankName: string;
|
||||||
|
*
|
||||||
|
* onBankNameChange(bankName: string) {
|
||||||
|
* this.bankName = bankName;
|
||||||
|
* }
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue